using Microsoft.AspNetCore.Mvc;
using Rhea.Common;
using SqlSugar;
using System.Threading.Tasks;
using Tiger.IBusiness;
using Tiger.Model;
using Tiger.Model.Entitys.MES.BizMesWo;
using Tiger.Model.Entitys.MES.BizMesWoBatch;
using Tiger.Api.iBiz;
using Newtonsoft.Json;
using Tiger.Model.Entitys.MES.Position;
namespace Tiger.Api.Controllers.MES
{
public partial class MESController : ControllerBase
{
///
/// 保存工单
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task SaveMesWo([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().SaveMesWo(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 下发保存批次工单
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task SaveMesBatchWo([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().SaveMesBatchWo(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 删除工单
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task DeleteMesWo([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().DeleteMesWo(action.Data?.ToString()));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 更新工单状态
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task UpdateWoStatus([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().UpdateWoStatus(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 更新工单批次状态
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task UpdateWoBatchStatus([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().UpdateWoBatchStatus(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 从工单中解绑正在生产的条码
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task UnbindWipSnFromWO([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().UnbindWipSnFromWO(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 更新工单模板变量
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task AddOrEditLabelVarByWorkOrder([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().AddOrEditLabelVarByWorkOrder(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 获取工单模板变量
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetLabelVarByWorkOrder([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().GetLabelVarByWorkOrder(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task SavePrintLabelInAct([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().SavePrintLabelInAct(action.Data?.ToString()));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 获取重打标签信息
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetRePrintInfo([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().GetRePrintInfo(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 获取出货信息
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetShipList([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().GetShipList(action.Data));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 获取工单批次的数量汇总
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetWoBatchCount([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { BATCH = action.Data?.ToString()});
var dt = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_WO_BATCH_COUNT", pars);
response.Data = dt;
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetWoNodeBatchCount([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
SugarParameter[] pars = Biz.Db.Ado.GetParameters(new { BATCH = action.Data.BatchNo, NodeIdOrName=action.Data.NodeName });
var dt = Biz.Db.Ado.UseStoredProcedure().GetDataTable("SP_MES_GET_NODE_BATCH_COUNT", pars);
response.Data = dt;
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
///
/// 生成入库获取条码工单信息及包装信息
///
///
///
[HttpPost]
[Route("api/[controller]/[action]")]
public async Task GetErpProdInBth([FromBody] ApiAction action)
{
ApiAction response = new();
try
{
response = response.GetResponse(await DI.Resolve().GetErpProdInBth(action.Data?.ToString()));
}
catch (System.Exception ex)
{
response = response.GetResponse().CatchExceptionWithLog(ex);
}
return Ok(response);
}
}
}