129 lines
3.6 KiB
C#
129 lines
3.6 KiB
C#
using DOAN.Model.Dto;
|
|
using DOAN.Model.MES.andon;
|
|
using DOAN.Service.MES.andon.IService;
|
|
using DOAN.ServiceCore.Signalr;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace DOAN.WebApi.Controllers.MES.andon
|
|
{
|
|
/// <summary>
|
|
/// 安灯交互
|
|
/// </summary>
|
|
|
|
[Route("mes/andonManagement/interaction")]
|
|
public class AndonInteractionController : BaseController
|
|
{
|
|
private IAndonInteractionService _andonInteractionService;
|
|
|
|
private readonly IHubContext<PDAMessageHub> _hubContext;
|
|
|
|
public AndonInteractionController(IAndonInteractionService andonInteractionService, IHubContext<PDAMessageHub> hubContext)
|
|
{
|
|
_andonInteractionService = andonInteractionService;
|
|
_hubContext = hubContext;
|
|
}
|
|
|
|
|
|
//TODO 获取线别
|
|
[HttpGet("get_line")]
|
|
public IActionResult GetLine()
|
|
{
|
|
var response = _andonInteractionService.GetLine();
|
|
return SUCCESS(response);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 呼叫请求
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("Call")]
|
|
public IActionResult CallHandle([FromBody] AndonAskQueryDto query)
|
|
{
|
|
if (query == null)
|
|
{
|
|
return SUCCESS(null);
|
|
|
|
}
|
|
AndonFaultRecord record = query.Adapt<AndonFaultRecord>();
|
|
record.ToCreate(HttpContext);
|
|
var response = _andonInteractionService.CallHandle(record);
|
|
|
|
//TODO 通知到PDA 发消息
|
|
_hubContext.Clients.All.SendAsync("Call", query);
|
|
|
|
return SUCCESS(response);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 呼叫请求 SCREEN
|
|
/// </summary>
|
|
/// <param name="query"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("Call_SCREEN")]
|
|
public IActionResult CallHandleSCREEN([FromBody] AndonAskQueryDto query)
|
|
{
|
|
if (query == null)
|
|
{
|
|
return SUCCESS(null);
|
|
|
|
}
|
|
AndonFaultRecord record = query.Adapt<AndonFaultRecord>();
|
|
record.ToCreate(HttpContext);
|
|
var response = _andonInteractionService.CallHandleSCREEN(record);
|
|
|
|
//TODO 通知到PDA 发消息
|
|
_hubContext.Clients.All.SendAsync("Call", query);
|
|
|
|
return SUCCESS(response);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// test手环 http://localhost:7000/mes/andonManagement/interaction/test
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("test")]
|
|
public IActionResult TestWatch()
|
|
{
|
|
|
|
var response = _andonInteractionService.TestWatch();
|
|
return SUCCESS(response);
|
|
}
|
|
/// <summary>
|
|
/// 获取待响应的 记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("waitingResponse")]
|
|
public IActionResult WaitingResponse()
|
|
{
|
|
var response = _andonInteractionService.WaitingResponse();
|
|
return SUCCESS(response);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 签到
|
|
/// </summary>
|
|
/// <param name="response"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("signin")]
|
|
public IActionResult SignIn([FromBody] AndonResponseQueryDto response)
|
|
{
|
|
if (response == null||response.Id==null)
|
|
{
|
|
return SUCCESS(null);
|
|
|
|
}
|
|
AndonFaultRecord record = response.Adapt<AndonFaultRecord>();
|
|
record.ToUpdate(HttpContext);
|
|
var res = _andonInteractionService.SignIn(record);
|
|
return SUCCESS(res);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|