1
z8018
2025-04-16 1f361850d35ba47225951efbc49d592eea685cf8
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
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar.Extensions;
using WIDESEAWCS_BasicInfoRepository;
using WIDESEAWCS_Common;
using WIDESEAWCS_Core;
using WIDESEAWCS_Core.BaseController;
using WIDESEAWCS_IBasicInfoRepository;
using WIDESEAWCS_IBasicInfoService;
using WIDESEAWCS_Model.Models;
 
namespace WIDESEAWCS_Server.Controllers.BasicInfo
{
    [Route("api/Container")]
    [ApiController]
    public class ContainerController : ApiBaseController<IContainerService, Dt_Container>
    {
        private readonly IContainerRepository _containerRepository;
        private readonly IOrderContainerRepository _orderContainerRepository;
        private readonly IOrderDetailsRepository _orderDetailsRepository;
        private readonly IOrderrowsRepository _orderrowsRepository;
        public ContainerController(IContainerService service, IContainerRepository containerRepository, IOrderContainerRepository orderContainerRepository, IOrderDetailsRepository orderDetailsRepository, IOrderrowsRepository orderrowsRepository) : base(service)
        {
            _containerRepository = containerRepository;
            _orderContainerRepository = orderContainerRepository;
            _orderDetailsRepository = orderDetailsRepository;
            _orderrowsRepository = orderrowsRepository;
        }
 
        [HttpPost, HttpGet, Route("GetPutStations"), AllowAnonymous]
        public WebResponseContent GetPutStations(string deviceCode)
        {
            try
            {
                List<Dt_Container> containers = _containerRepository.QueryData(=> x.DeviceCode == deviceCode && x.ContainerType == ContainerTypeEnum.PutContainer.ObjToInt());
                List<object> list = new List<object>();
                foreach (var container in containers)
                {
                    Dt_OrderContainer orderContainer = _orderContainerRepository.QueryFirst(=> x.ContainerId == container.Id && x.ContainerCode == container.ContainerCode);
                    if (orderContainer != null)
                    {
                        Orderrows orderrows = _orderrowsRepository.QueryFirst(=> x.id == orderContainer.OrderId);
                        if (orderrows != null)
                        {
                            List<OrderDetails> totalDetails = _orderDetailsRepository.QueryData(=> x.Orderrowsid == orderrows.id);
                            List<OrderDetails> details = totalDetails.Where(=> x.Orderrowsid == orderrows.id && x.Orderdetails_status == PalletingStatusEnmu.PalletingSuccess.ObjToInt()).ToList();
                            List<object> orderData = new List<object>();
                            foreach (var item in details)
                            {
                                object obj = new
                                {
                                    orderCode = orderrows.Orderrows_orderid,
                                    cusName = orderrows.Orderrows_customer,
                                    orderName = orderrows.Orderrows_name,
                                    batch = orderrows.Orderrows_batchid,
                                    productName = ""
                                };
                                orderData.Add(obj);
                            }
                            object data = new
                            {
                                stationCode = container.ContainerCode,
                                orderTotalNum = totalDetails.Count,
                                sortedNum = details.Count,
                                unsortedNum = totalDetails.Count - details.Count,
                                orderData = orderData
                            };
                            list.Add(data);
                        }
                        else
                        {
                            object data = new
                            {
                                stationCode = container.ContainerCode,
                                orderTotalNum = 0,
                                sortedNum = 0,
                                unsortedNum = 0,
                                orderData = new List<object>()
                            };
                            list.Add(data);
                        }
                    }
                    else
                    {
                        object data = new
                        {
                            stationCode = container.ContainerCode,
                            orderTotalNum = 0,
                            sortedNum = 0,
                            unsortedNum = 0,
                            orderData = new List<object>()
                        };
                        list.Add(data);
                    }
                }
 
                return WebResponseContent.Instance.OK(data: list);
            }
            catch (Exception ex)
            {
                return new WebResponseContent()
                {
                    Code = 500,
                    Message = ex.Message
                };
            }
        }
    }
}