dengjunjie
2025-05-20 be484c84a25d1f6c769e7b5e958048d745942e55
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using SqlSugar.Extensions;
using System.Threading.Tasks;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Core;
using WIDESEA_Core.Enums;
using WIDESEA_DTO.LargeScreen;
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
using WIDESEA_IOutboundRepository;
using WIDESEA_IStockRepository;
using WIDESEA_ITaskInfoRepository;
using WIDESEA_Model.Models;
using WIDESEAWCS_DTO.WCSInfo;
 
namespace WIDESEA_WMSServer.Controllers
{
    [Route("api/LargeScreen")]
    [ApiController, AllowAnonymous]
    public class LargeScreenController : Controller
    {
        private readonly ILocationInfoService _locationInfoService;
        private readonly ITaskRepository _taskRepository;
        private readonly ITask_HtyRepository _taskHtyRepository;
        private readonly IStockInfoDetailRepository _stockInfoDetailRepository;
        private readonly IInboundOrderDetailRepository _inboundOrderDetailRepository;
        private readonly IInboundOrderRepository _inboundOrderRepository;
        private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository;
        private readonly IOutboundOrderRepository _outboundOrderRepository;
        public LargeScreenController(ILocationInfoService locationInfoService, ITaskRepository taskRepository, ITask_HtyRepository taskHtyRepository, IInboundOrderDetailRepository inboundOrderDetailRepository, IInboundOrderRepository inboundOrderRepository, IOutboundOrderDetailRepository outboundOrderDetailRepository, IOutboundOrderRepository outboundOrderRepository, IStockInfoDetailRepository stockInfoDetailRepository)
        {
            _locationInfoService = locationInfoService;
            _taskRepository = taskRepository;
            _taskHtyRepository = taskHtyRepository;
            _inboundOrderDetailRepository = inboundOrderDetailRepository;
            _inboundOrderRepository = inboundOrderRepository;
            _outboundOrderDetailRepository = outboundOrderDetailRepository;
            _outboundOrderRepository = outboundOrderRepository;
            _stockInfoDetailRepository = stockInfoDetailRepository;
        }
        [HttpPost, Route("GetStockInfos")]
        public WebResponseContent GetStockInfos()
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            List<Dt_StockInfoDetail> _StockInfoDetails = _stockInfoDetailRepository.QueryData(x => x.Status == StockStatusEmun.已入库.ObjToInt());
            List<StockInfo> stocks = new List<StockInfo>();
            foreach (var item in _StockInfoDetails.GroupBy(x => x.MaterielCode))
            {
                StockInfo stockInfo = new StockInfo()
                {
                    Name = item.First().MaterielName,
                    Qty = item.ToList().Count()
                };
                stocks.Add(stockInfo);
            }
            return webResponseContent.OK(data: stocks.OrderByDescending(x => x.Qty));
        }
        public class StockInfo
        {
            public string Name { get; set; }
            public int Qty { get; set; }
        }
        [HttpPost, Route("GetLocationInfo")]
        public WebResponseContent GetLocationInfo([FromBody] SaveModel model)
        {
            return _locationInfoService.GetLocationInfo(model);
        }
        /// <summary>
        /// 获取工单信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("GetBoundOrder")]
        public WebResponseContent GetBoundOrder([FromBody] SaveModel model)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            try
            {
                var name = model.MainData["Name"].ToString();
                List<BoundOrderDTO> boundOrderDTOs = new List<BoundOrderDTO>();
                if (name == "入库")
                {
                    List<Dt_InboundOrder> inboundOrders = _inboundOrderRepository.QueryData(x => true);
                    List<Dt_InboundOrderDetail> inboundOrderDetails = _inboundOrderDetailRepository.QueryData(y => inboundOrders.Select(x => x.Id).ToList().Contains(y.OrderId));
                    foreach (var item in inboundOrderDetails)
                    {
                        Dt_InboundOrder _InboundOrder = inboundOrders.Where(x => x.Id == item.OrderId).First();
                        BoundOrderDTO boundOrderDTO = new BoundOrderDTO()
                        {
                            OrderNo = _InboundOrder.OrderNo,
                            BatchNo = item.BatchNo,
                            MaterielCode = item.MaterielCode,
                            MaterielName = item.MaterielName,
                            OrderDetailStatus = item.OrderDetailStatus,
                            OrderQuantity = item.OrderQuantity,
                            OrderType = _InboundOrder.OrderType,
                            OverInQuantity = item.OverInQuantity,
                        };
                        boundOrderDTOs.Add(boundOrderDTO);
                    }
                }
                else
                {
                    List<Dt_OutboundOrder> outboundOrders = _outboundOrderRepository.QueryData(x => true);
                    List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundOrderDetailRepository.QueryData(y => outboundOrders.Select(x => x.Id).ToList().Contains(y.OrderId));
                    foreach (var item in outboundOrderDetails)
                    {
                        Dt_OutboundOrder _OutboundOrder = outboundOrders.Where(x => x.Id == item.OrderId).First();
                        BoundOrderDTO boundOrderDTO = new BoundOrderDTO()
                        {
                            OrderNo = _OutboundOrder.OrderNo,
                            BatchNo = item.BatchNo,
                            MaterielCode = item.MaterielCode,
                            MaterielName = item.MaterielName,
                            OrderDetailStatus = item.OrderDetailStatus,
                            OrderQuantity = item.OrderQuantity,
                            OrderType = _OutboundOrder.OrderType,
                            OverInQuantity = item.OverOutQuantity,
                        };
                        boundOrderDTOs.Add(boundOrderDTO);
                    }
                }
                webResponseContent.OK(data: boundOrderDTOs);
            }
            catch (Exception ex)
            {
                webResponseContent.Error(ex.Message);
            }
            return webResponseContent;
        }
        [HttpPost, Route("GetTaskInfos")]
        public WebResponseContent GetTaskInfos()
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var date = DateTime.Now;
            var date1 = DateTime.Today.AddDays(-1);
            List<Dt_Task_Hty> Task_YearHties = _taskHtyRepository.QueryData(x => x.InsertTime.Year == date.Year).ToList();
            List<Dt_Task_Hty> Task_Hties = Task_YearHties.Where(x => x.InsertTime.Date == date.Date).ToList();
            List<Dt_Task_Hty> ZTask_Hties = Task_YearHties.Where(x => x.InsertTime.Date == date1.Date).ToList();
 
            List<Dt_Task_Hty> _Task_InYearHties = Task_YearHties.Where(x => x.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt() || x.TaskType == TaskInboundTypeEnum.PalletInbound.ObjToInt()).ToList();
            List<Dt_Task_Hty> _Task_OutYearHties = Task_YearHties.Where(x => x.TaskType == TaskOutboundTypeEnum.Outbound.ObjToInt() || x.TaskType == TaskOutboundTypeEnum.PalletOutbound.ObjToInt()).ToList();
 
            List<Dt_Task_Hty> _Task_InMonthHties = _Task_InYearHties.Where(x => x.InsertTime.Month == date.Month).ToList();
            List<Dt_Task_Hty> _Task_OutMonthHties = _Task_OutYearHties.Where(x => x.InsertTime.Month == date.Month).ToList();
 
            List<Dt_Task_Hty> _Task_InHties = _Task_InMonthHties.Where(x => x.InsertTime.Day == date.Day).ToList();
            List<Dt_Task_Hty> _Task_OutHties = _Task_OutMonthHties.Where(x => x.InsertTime.Day == date.Day).ToList();
            List<Dt_Task_Hty> _Task_ZInHties = _Task_InMonthHties.Where(x => x.InsertTime.Day == date1.Day).ToList();
            List<Dt_Task_Hty> _Task_ZOutHties = _Task_OutMonthHties.Where(x => x.InsertTime.Day == date1.Day).ToList();
            webResponseContent.OK(data: new
            {
                InYearHties = _Task_InYearHties.Count,
                OutYearHties = _Task_OutYearHties.Count,
                InMonthHties = _Task_InMonthHties.Count,
                OutMonthHties = _Task_OutMonthHties.Count,
                InHties = _Task_InHties.Count,
                OutHties = _Task_OutHties.Count,
                Hties = Task_Hties.Count,
                ZHties = ZTask_Hties.Count,
                ZInHties = _Task_ZInHties.Count,
                ZOutHties = _Task_ZOutHties.Count,
            });
            return webResponseContent;
        }
 
        [HttpPost, Route("GetTask")]
        public WebResponseContent GetTask([FromBody] SaveModel model)
        {
            WebResponseContent webResponseContent = new WebResponseContent();
            var name = model.MainData["Name"].ToString();
 
            List<Dt_Task_Hty> task_Hties = new List<Dt_Task_Hty>();
            if (name != "入库")
            {
                task_Hties = _taskHtyRepository.QueryData(x => x.TaskType == TaskOutboundTypeEnum.Outbound.ObjToInt() || x.TaskType == TaskOutboundTypeEnum.PalletOutbound.ObjToInt()).ToList();
                var task_htys = task_Hties.Where(x => x.InsertTime.Date == DateTime.Now.Date).ToList();
                var tasks = _taskRepository.QueryData(x => x.TaskType == TaskOutboundTypeEnum.Outbound.ObjToInt() || x.TaskType == TaskOutboundTypeEnum.PalletOutbound.ObjToInt()).ToList();
 
                List<Dt_OutboundOrderDetail> outboundOrderDetails = _outboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus < OrderDetailStatusEnum.Outbound.ObjToInt()).ToList();
                webResponseContent.OK(data: new
                {
                    task_Htiesqty = task_Hties.Count,
                    task_htysqty = task_htys.Count,
                    tasksqty = tasks.Count,
                    inboundOrderDetailsqty = outboundOrderDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity)
                });
            }
            else
            {
                task_Hties = _taskHtyRepository.QueryData(x => x.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt() || x.TaskType == TaskInboundTypeEnum.PalletInbound.ObjToInt()).ToList();
                var task_htys = task_Hties.Where(x => x.InsertTime.Date == DateTime.Now.Date).ToList();
                var tasks = _taskRepository.QueryData(x => x.TaskType == TaskInboundTypeEnum.Inbound.ObjToInt() || x.TaskType == TaskInboundTypeEnum.PalletInbound.ObjToInt()).ToList();
 
                List<Dt_InboundOrderDetail> inboundOrderDetails = _inboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus <= OrderDetailStatusEnum.GroupAndInbound.ObjToInt()).ToList();
                webResponseContent.OK(data: new
                {
                    task_Htiesqty = task_Hties.Count,
                    task_htysqty = task_htys.Count,
                    tasksqty = tasks.Count,
                    inboundOrderDetailsqty = inboundOrderDetails.Sum(x => x.OrderQuantity - x.OverInQuantity)
                });
            }
            return webResponseContent;
        }
    }
}