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 => 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 => x.ContainerId == container.Id && x.ContainerCode == container.ContainerCode);
|
if (orderContainer != null)
|
{
|
Orderrows orderrows = _orderrowsRepository.QueryFirst(x => x.id == orderContainer.OrderId);
|
if (orderrows != null)
|
{
|
List<OrderDetails> totalDetails = _orderDetailsRepository.QueryData(x => x.Orderrowsid == orderrows.id);
|
List<OrderDetails> details = totalDetails.Where(x => 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
|
};
|
}
|
}
|
}
|
}
|