using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using SqlSugar; using SqlSugar.Extensions; 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_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 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) { _locationInfoService = locationInfoService; _taskRepository = taskRepository; _taskHtyRepository = taskHtyRepository; _inboundOrderDetailRepository = inboundOrderDetailRepository; _inboundOrderRepository = inboundOrderRepository; _outboundOrderDetailRepository = outboundOrderDetailRepository; _outboundOrderRepository = outboundOrderRepository; } [HttpPost, Route("GetLocationInfo")] public WebResponseContent GetLocationInfo([FromBody] SaveModel model) { return _locationInfoService.GetLocationInfo(model); } /// /// 获取工单信息 /// /// /// [HttpPost, Route("GetBoundOrder")] public WebResponseContent GetBoundOrder([FromBody] SaveModel model) { WebResponseContent webResponseContent = new WebResponseContent(); try { var name = model.MainData["Name"].ToString(); List boundOrderDTOs = new List(); if (name == "入库") { List inboundOrders = _inboundOrderRepository.QueryData(x => true); List 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 outboundOrders = _outboundOrderRepository.QueryData(x => true); List 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("GetTask")] public WebResponseContent GetTask([FromBody] SaveModel model) { var name = model.MainData["Name"].ToString(); List task_Hties = _taskHtyRepository.QueryData(x => x.TaskType == (name == "入库" ? TaskInboundTypeEnum.Inbound.ObjToInt() : TaskOutboundTypeEnum.Outbound.ObjToInt())).ToList(); var task_htys = task_Hties.Where(x => x.InsertTime.Date == DateTime.Now.Date).ToList(); var tasks = _taskRepository.QueryData(x => x.TaskType == (name == "入库" ? TaskInboundTypeEnum.Inbound.ObjToInt() : TaskOutboundTypeEnum.Outbound.ObjToInt())).ToList(); List inboundOrderDetails = _inboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus <= OrderDetailStatusEnum.GroupAndInbound.ObjToInt()).ToList(); if (name != "入库") { List outboundOrderDetails = _outboundOrderDetailRepository.QueryData(x => x.OrderDetailStatus < OrderDetailStatusEnum.Outbound.ObjToInt()).ToList(); return WebResponseContent.Instance.OK(data: new { task_Htiesqty = task_Hties.Count, task_htysqty = task_htys.Count, tasksqty = tasks.Count, inboundOrderDetailsqty = outboundOrderDetails.Sum(x => x.OrderQuantity - x.OverOutQuantity) }); } return WebResponseContent.Instance.OK(data: new { task_Htiesqty = task_Hties.Count, task_htysqty = task_htys.Count, tasksqty = tasks.Count, inboundOrderDetailsqty = inboundOrderDetails.Sum(x => x.OrderQuantity - x.OverInQuantity) }); } } }