using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using WIDESEA_Core.Attributes;
using WIDESEA_Core;
using WIDESEA_DTO;
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_ITaskInfoService;
using WIDESEA_TaskInfoService;
using WIDESEA_DTO.ERP;
using WIDESEA_DTO.MES;
using WIDESEA_Core.Helper;
using Autofac.Core;
using WIDESEA_DTO.Stock;
using WIDESEA_Common.TaskEnum;
using WIDESEA_Common.LocationEnum;
using System.Collections.Generic;
using WIDESEA_Model.Models;
using SqlSugar;
using WIDESEA_IStockService;
using WIDESEA_Common.StockEnum;
using HslCommunication.WebSocket;
namespace WIDESEA_WMSServer.Controllers.LargeScreen
{
[Route("api/Large")]
[ApiController]
public class LargeController : ControllerBase
{
private readonly IOutboundService _outboundService;
private readonly ITaskService _taskService;
private readonly ITask_HtyService _task_HtyService;
private readonly IBasicService _basicService;
private readonly IMesProInOrderService _mesProInOrderService;
private readonly IOutProStockInfoService _outProStockInfoService;
private readonly WebSocketServer _webSocketServer;
private readonly IProStockInfoDetailService _proStockInfoDetailService;
private readonly IProStockInfoService _proStockInfoService;
public LargeController(IOutboundService outboundService, ITaskService taskService, ITask_HtyService task_HtyService, IBasicService basicService, IMesProInOrderService mesProInOrderService, IOutProStockInfoService outProStockInfoService, IProStockInfoDetailService proStockInfoDetailService, IProStockInfoService proStockInfoService, WebSocketServer webSocketServer)
{
_outboundService = outboundService;
_taskService = taskService;
_task_HtyService = task_HtyService;
_basicService = basicService;
_mesProInOrderService = mesProInOrderService;
_outProStockInfoService = outProStockInfoService;
_proStockInfoDetailService = proStockInfoDetailService;
_proStockInfoService = proStockInfoService;
_webSocketServer = webSocketServer;
}
///
/// 测试
///
///
[HttpPost, Route("PushInfoSocket"), AllowAnonymous]
public WebResponseContent ProMonthTaskStatistics(string info)
{
WebSocketSession[] webSocketSession = _webSocketServer.OnlineSessions;
if (webSocketSession != null)
{
_webSocketServer.SendClientPayload(webSocketSession[0], "同意");
}
return WebResponseContent.Instance.OK(_webSocketServer.OnlineSessions.Select(x=>x.Url).Serialize());
}
/////
///// 成品当月任务统计
/////
/////
/////
//[HttpPost, Route("ProMonthTaskStatistics"), AllowAnonymous]
//public WebResponseContent ProMonthTaskStatistics()
//{
// WebResponseContent content = new WebResponseContent();
// try
// {
// //获取当月成品的任务总量
// int inboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.InProduct.ObjToInt()).Count;
// int outboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.OutProduct.ObjToInt()).Count;
// int backboundCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.EmptyProductBack.ObjToInt()).Count;
// int surplusCount = _taskService.Repository.QueryData(x => x.TaskType == TaskTypeEnum.InProductBack.ObjToInt()).Count;
// content.OK("成功", new { inboundCount, outboundCount, backboundCount, surplusCount });
// }
// catch (Exception ex)
// {
// content.Error(ex.Message);
// }
// return content;
//}
/////
///// 成品货位
/////
/////
/////
//[HttpPost, Route("ProLocationStatistics"), AllowAnonymous]
//public WebResponseContent ProLocationStatistics(int Id)
//{
// WebResponseContent content = new WebResponseContent();
// try
// {
// //获取成品的货位
// int freeCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && x.WarehouseId == Id).Count;
// int inStockCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.WarehouseId == Id).Count;
// int lockCount = _basicService.LocationInfoService.Repository.QueryData(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && x.WarehouseId == Id).Count;
// content.OK("成功", new { freeCount, inStockCount, lockCount });
// }
// catch (Exception ex)
// {
// content.Error(ex.Message);
// }
// return content;
//}
/////
///// 成品入库产量
/////
/////
/////
//[HttpPost, Route("Productions"), AllowAnonymous]
//public WebResponseContent Productions()
//{
// WebResponseContent content = new WebResponseContent();
// try
// {
// List