using CMS.Extensions.Abp.AspNetCore.Mvc.Filters;
using CMS.Framework.AspNetCore.Users;
using CMS.Plugin.PipeLineLems.Application.Contracts.Dtos.WorkPlan;
using CMS.Plugin.PipeLineLems.Application.Contracts.Services;
using CMS.Plugin.PipeLineLems.Application.Implements;
using CmsQueryExtensions;
using CmsQueryExtensions.Entitys;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Reflection;
namespace CMS.Plugin.PipeLineLems.Controller
{
///
/// 作业计划服务
///
[ApiController]
[TypeFilter(typeof(CMSLanguageFilter))]
[TypeFilter(typeof(CMSUowActionFilter))]
[TypeFilter(typeof(CMSAuditActionFilter))]
[TypeFilter(typeof(CMSExceptionFilter))]
[Route("api/v{version:apiVersion}/PipeLineLems/[controller]")]
public class WorkPlanPublicController : ControllerBase
{
private readonly IWorkPlanAppService _workPlanAppService;
private readonly IMesAppService _mesAppService;
private readonly ICurrentUser _currentUser;
private readonly Application.Implements.SharedService sharedService;
private IServiceProvider _serviceProvider;
///
/// Initializes a new instance of the class.
///
/// The testentityname application service.
public WorkPlanPublicController(IMesAppService mesAppService, ICurrentUser currentUser, Application.Implements.SharedService _sharedService,
IServiceProvider serviceProvider, IWorkPlanAppService workPlanAppService)
{
_mesAppService = mesAppService;
_currentUser = currentUser;
sharedService = _sharedService;
_serviceProvider = serviceProvider;
_workPlanAppService = workPlanAppService;
}
///
/// 获取生产计划.
///
/// 标识符.
///
[HttpPost]
public virtual async Task GetWorkPlanAsync([FromBody] List input)
{
return await _mesAppService.CreateAsync(input, "", "");
}
///
/// 分拣
///
/// 标识符.
///
[Authorize]
[HttpPost]
[Route("Pick")]
public virtual async Task Pick([FromBody] PickInput input)
{
try
{
MyCurrentUser myCurrentUser = new MyCurrentUser()
{
UserAccount = _currentUser.UserAccount,
UserId = _currentUser.UserId
};
return await sharedService.CommonPick(_serviceProvider, input, myCurrentUser);
}
catch (Exception ex)
{
return new MesOrderResponse()
{
Code = "400",
Message = ex.Message
};
}
}
///
/// 叫料
///
/// 标识符.
///
[Authorize]
[HttpPost]
[Route("CallMaterial")]
public virtual async Task CallMaterial([FromBody] CallMaterialByDataIdentifierInput input)
{
try
{
MyCurrentUser myCurrentUser = new MyCurrentUser()
{
UserAccount = _currentUser.UserAccount,
UserId = _currentUser.UserId
};
return await sharedService.CallMaterial(input, _serviceProvider, myCurrentUser);
}
catch (Exception ex)
{
return new MesOrderResponse()
{
Code = "400",
Message = ex.Message
};
}
}
///
/// 开工
///
///
///
[Authorize]
[HttpPost]
[Route("StartProduction")]
public virtual async Task StartProduction([FromBody] StartProductionInput input)
{
try
{
MyCurrentUser myCurrentUser = new MyCurrentUser()
{
UserAccount = _currentUser.UserAccount,
UserId = _currentUser.UserId
};
return await sharedService.StartProduction(input, _serviceProvider, myCurrentUser);
}
catch (Exception ex)
{
return new MesOrderResponse()
{
Code = "400",
Message = ex.Message
};
}
}
///
/// 完工
///
///
///
[Authorize]
[HttpPost]
[Route("FinishProduction")]
public virtual async Task FinishProduction([FromBody] CompleteAssemblyProcessInput input)
{
try
{
MyCurrentUser myCurrentUser = new MyCurrentUser()
{
UserAccount = _currentUser.UserAccount,
UserId = _currentUser.UserId
};
return await sharedService.CompleteAssemblyProcess(_serviceProvider, input, myCurrentUser);
}
catch (Exception ex)
{
return new MesOrderResponse()
{
Code = "400",
Message = ex.Message
};
}
}
///
/// 分拣时获取生产计划和分配区域
///
///
///
[HttpPost]
[Route("GetPickRet")]
public virtual async Task> GetPickRetAsync([FromBody] GetWorkPlanInput input)
{
//WorkPlanDto workPlanDto = await _workPlanAppService.FindSingleByFilterAsync(input);
////这里要获取wms的库存,来分析 要放到哪个托盘里
//return new PickOutput()
//{
// WorkPlan = workPlanDto,
// PlaceNo = "",
// ContinerNo = ""
//};
try
{
MyCurrentUser myCurrentUser = new MyCurrentUser()
{
UserAccount = _currentUser.UserAccount,
UserId = _currentUser.UserId
};
return await sharedService.GetPickRetAsync(input, _serviceProvider, myCurrentUser);
}
catch (Exception ex)
{
return new CmsApiResponse()
{
Code = 400,
Message = ex.Message
};
}
}
}
}