using MES.Service.Dto.service;
|
using MES.Service.Modes;
|
using MES.Service.service;
|
using MES.Service.service.Warehouse;
|
using MES.Service.util;
|
using Microsoft.AspNetCore.Mvc;
|
using Newtonsoft.Json;
|
|
namespace MESApplication.Controllers.Warehouse
|
{
|
[ApiController]
|
[Route("api/[controller]")]
|
public class MesPalletBinding1Controller : ControllerBase
|
{
|
private readonly MessageCenterManager _manager = new();
|
private readonly MesPalletBinding1Manager m = new();
|
private readonly string METHOD = "POST";
|
private readonly string TableName = "mespalletbinding1";
|
|
private readonly string URL =
|
"http://localhost:10054/api/mespalletbinding1/";
|
|
/// <summary>
|
/// 从外部接口获取栈板绑定信息并保存到数据库
|
/// </summary>
|
/// <param name="palletBinding">栈板绑定信息</param>
|
/// <returns></returns>
|
[HttpPost("SavePalletBindingData")]
|
public ResponseResult SavePalletBindingData([FromBody] MesPalletBinding palletBinding)
|
{
|
try
|
{
|
// 调用业务逻辑层方法将数据保存到数据库
|
int insertedCount = m.InsertPalletBindingData(palletBinding);
|
|
if (insertedCount > 0)
|
{
|
return new ResponseResult
|
{
|
status = 0,
|
message = $"成功插入 {insertedCount} 条栈板绑定数据",
|
data = insertedCount
|
};
|
}
|
else
|
{
|
return new ResponseResult
|
{
|
status = 1,
|
message = "未插入任何数据,可能是因为接口返回的数据为空",
|
data = null
|
};
|
}
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 检查栈板码在数据库中是否存在
|
/// </summary>
|
/// <param name="stackCode">栈板码</param>
|
/// <returns></returns>
|
[HttpPost("CheckStackCodeExists")]
|
public ResponseResult CheckStackCodeExists([FromBody] dynamic request)
|
{
|
try
|
{
|
string stackCode = request.stackCode;
|
bool exists = m.CheckStackCodeExists(stackCode);
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = exists ? "栈板码已存在" : "栈板码不存在",
|
data = exists
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 从外部接口获取栈板绑定信息并保存到数据库(带存在性检查)
|
/// </summary>
|
/// <param name="palletBinding">栈板绑定信息</param>
|
/// <returns></returns>
|
[HttpPost("SavePalletBindingDataWithCheck")]
|
public async Task<ResponseResult> SavePalletBindingDataWithCheck([FromBody] MesPalletBinding palletBinding)
|
{
|
try
|
{
|
// 调用业务逻辑层方法将数据保存到数据库(带存在性检查)
|
int result = await m.InsertPalletBindingDataWithCheckAsync(palletBinding);
|
|
return new ResponseResult
|
{
|
status = 0,
|
message = result > 0 ? $"成功处理 {result} 条栈板绑定数据" : "未处理任何数据,可能是因为接口返回的数据为空",
|
data = result
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
}
|
}
|