heshaofeng
2025-12-29 266e4bf654c55ce2f7e9271048e4625f1b8b49f6
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using WIDESEA_Core;
using WIDESEA_DTO.CalcOut;
 
namespace WIDESEA_WMSServer.Controllers.Outbound
{
    [Route("api/[controller]")]
    [ApiController]
    public class OutboundController : ControllerBase
    {
        private readonly WIDESEA_IOutboundService.IOutboundService _outboundService;
        public OutboundController(WIDESEA_IOutboundService.IOutboundService outboundService)
        {
            _outboundService = outboundService;
        }
 
        /// <summary>
        /// 分拣出库操作
        /// </summary>
        /// <param name="request">分拣出库请求</param>
        /// <returns>分拣出库响应</returns>
        [HttpPost, Route("ProcessPickingOutbound"), AllowAnonymous]
        public WebResponseContent ProcessPickingOutbound([FromBody] PickingOutboundRequestDTO request)
        {
            try
            {
                if (!ModelState.IsValid)
                    return WebResponseContent.Instance.Error(string.Join("; ", ModelState.Values
                        .SelectMany(v => v.Errors)
                        .Select(e => e.ErrorMessage)));
 
                return _outboundService.ProcessPickingOutbound(request);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error($"分拣出库操作失败: {ex.Message}");
            }
        }
 
        object lockObj = new object();
 
        [HttpPost, Route("CompleteOutboundWithBarcode"), AllowAnonymous]
        public WebResponseContent CompleteOutboundWithBarcode([FromBody] OutboundCompleteRequestDTO request)
        {
            try
            {
                lock (lockObj)
                {
                    if (!ModelState.IsValid)
                        return WebResponseContent.Instance.Error(string.Join("; ", ModelState.Values
                            .SelectMany(v => v.Errors)
                            .Select(e => e.ErrorMessage)));
 
                    return _outboundService.CompleteOutboundWithBarcode(request);
                }
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error($"出库扫描操作失败: {ex.Message}");
            }
        }
 
        [HttpPost, Route("CompleteOutboundWithPallet"), AllowAnonymous]
        public WebResponseContent CompleteOutboundWithPallet([FromBody] OutboundCompletePalletRequestDTO request)
        {
            try
            {
                lock (lockObj)
                {
                    if (!ModelState.IsValid)
                        return WebResponseContent.Instance.Error(string.Join("; ", ModelState.Values
                            .SelectMany(v => v.Errors)
                            .Select(e => e.ErrorMessage)));
 
                    return _outboundService.CompleteOutboundWithPallet(request);
                }
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error($"整箱出库操作失败: {ex.Message}");
            }
        }
 
        [HttpPost,HttpGet, Route("GetOrderInfo"), AllowAnonymous]
        public WebResponseContent GetOrderInfo(string orderNo)
        {
            return _outboundService.GetOrderInfo(orderNo);
        }
 
        [HttpPost, Route("QueryPickingTasks"), AllowAnonymous]
        public WebResponseContent QueryPickingTasks(string palletCode, string orderNo)
        {
            return _outboundService.QueryPickingTasks(palletCode, orderNo);
        }
 
        [HttpPost, Route("QueryPickedList"), AllowAnonymous]
        public WebResponseContent QueryPickedList(string orderNo, string palletCode)
        {
            return _outboundService.QueryPickedList(orderNo, palletCode);
        }
 
        [HttpPost, Route("EmptyBox"), AllowAnonymous]
        public async Task<WebResponseContent> EmptyBox([FromBody] ReturnToWarehouseDTO returnToWarehouse)
        {
            return await _outboundService.EmptyBox(returnToWarehouse.palletCode);
        }
 
        [HttpPost, Route("ReturnToWarehouse"), AllowAnonymous]
        public async Task<WebResponseContent> ReturnToWarehouse([FromBody]ReturnToWarehouseDTO returnToWarehouse)
        {
            return await _outboundService.ReturnToWarehouse(returnToWarehouse.palletCode, returnToWarehouse.orderNo, returnToWarehouse.station);
        }
    }
}