using System.Dynamic;
using Microsoft.AspNetCore.Mvc;
using NewPdaSqlServer.Dto.service;
using NewPdaSqlServer.service.Warehouse;
using NewPdaSqlServer.util;
namespace NewPdaSqlServer.Controllers.Warehouse;
///
/// 其他入库相关接口
///
[Route("api/[controller]")]
[ApiController]
public class MesItemQtrkController : ControllerBase
{
private readonly MesItemQtrkManager _manager = new();
#region 基础CRUD
///
/// 获取所有
///
/// 其他入库单列表
[HttpPost("GetList")]
public ResponseResult GetList()
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = _manager.GetList();
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 根据主键获取
///
/// 其他入库单信息
[HttpPost("GetById")]
public ResponseResult GetById(int id)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = _manager.GetById(id);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
#endregion
#region 其他入库业务
///
/// 获取其他入库单号列表
///
/// 其他入库单号列表
///
/// 获取状态为已审核(Qt015=1)且未完结(Qt014=0)的其他入库单号列表
///
/// 成功获取入库单号列表
/// 获取失败
[HttpPost("GetQtckList")]
public ResponseResult GetQtckList()
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = _manager.GetQtckList();
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 获取其他入库单明细列表
///
/// 查询参数,必须包含billNo(入库单号)
/// 入库单明细列表
///
/// 请求示例:
/// POST /api/MesItemQtrk/GetQtckDetailList
/// {
/// "billNo": "QT202401010001"
/// }
/// 返回未完成入库的明细记录(Qd007-Qd008>0)
///
/// 成功获取入库单明细
/// 获取失败,返回具体错误信息
[HttpPost("GetQtckDetailList")]
public ResponseResult GetQtckDetailList([FromBody] WarehouseQuery query)
{
//try
//{
// dynamic resultInfos = new ExpandoObject();
// resultInfos.tbBillList = _manager.GetQtckDetailList(query);
// return new ResponseResult
// {
// status = 0,
// message = "OK",
// data = resultInfos
// };
//}
//catch (Exception ex)
//{
// return ResponseResult.ResponseError(ex);
//}
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.tbBillList = _manager.GetQtckDetailList(query);
//if(resultInfos.tbBillList.Count < 1)
//{
// return new ResponseResult
// {
// status = 1,
// message = "该申请单号不存在或未审核!!!",
// data = ""
// };
//}
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 扫描库位
///
/// 查询参数
/// 库位信息
///
/// 请求示例:
/// POST /api/MesItemQtrk/ScanInDepotsQT
/// {
/// "sectionCode": "A01-01-01",
/// "billNo": "QT202401010001"
/// }
/// 验证库位是否属于申请单指定的仓库
///
/// 扫描成功
/// 扫描失败,返回具体错误信息
[HttpPost("ScanInDepotsQT")]
public ResponseResult ScanInDepotsQT([FromBody] WarehouseQuery query)
{
try
{
dynamic resultInfos = new ExpandoObject();
resultInfos.message = _manager.ScanInDepotsQT(query);
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
///
/// 扫描条码入库
///
/// 查询参数
/// 入库结果和待处理明细
///
/// 请求示例:
/// POST /api/MesItemQtrk/ScanInBcodeQtrk
/// {
/// "userName": "admin",
/// "sectionCode": "A01-01-01",
/// "barcode": "BC001",
/// "billNo": "QT202401010001"
/// }
/// - 验证条码是否已入库
/// - 验证条码是否为其他入库条码
/// - 验证入库数量是否超过申请数量
/// - 执行入库事务处理
///
/// 扫描成功
/// 扫描失败,返回具体错误信息
[HttpPost("ScanInBcodeQtrk")]
public ResponseResult ScanInBcodeQtrk([FromBody] WarehouseQuery query)
{
try
{
dynamic resultInfos = new ExpandoObject();
var (form, items) = _manager.ScanInBcodeQtrk(query);
resultInfos.form = form;
resultInfos.items = items;
return new ResponseResult
{
status = 0,
message = "OK",
data = resultInfos
};
}
catch (Exception ex)
{
return ResponseResult.ResponseError(ex);
}
}
#endregion
}