using System.Dynamic;
|
using Microsoft.AspNetCore.Mvc;
|
using NewPdaSqlServer.Dto.service;
|
using NewPdaSqlServer.entity;
|
using NewPdaSqlServer.service.Warehouse;
|
using NewPdaSqlServer.util;
|
|
namespace NewPdaSqlServer.Controllers.Warehouse;
|
|
/// <summary>
|
/// 生产补料相关接口
|
/// </summary>
|
[Route("api/[controller]")]
|
[ApiController]
|
public class MesXsckController : ControllerBase
|
{
|
private readonly MesXsckManager _manager = new();
|
|
/***进入模版管理可以修改模版***/
|
|
/// <summary>
|
/// 获取所有
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 根据主键获取
|
/// </summary>
|
/// <returns></returns>
|
[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);
|
}
|
}
|
|
/// <summary>
|
/// 根据主键删除
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost("DeleteByIds")]
|
public ResponseResult DeleteByIds([FromBody] object[] ids)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.DeleteByIds(ids);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 添加
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost("Insert")]
|
public ResponseResult Add([FromBody] MesItemBl data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.Insert(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 添加返回自增
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost("InsertReturnIdentity")]
|
public ResponseResult InsertReturnIdentity([FromBody] MesItemBl data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.InsertReturnIdentity(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 修改
|
/// </summary>
|
/// <returns></returns>
|
[HttpPost("Update")]
|
public ResponseResult Update([FromBody] MesItemBl data)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.Update(data);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 生产补料单条码拆分
|
/// </summary>
|
/// <param name="query">查询参数</param>
|
/// <returns>拆分结果和待处理列表</returns>
|
/// <remarks>
|
/// 请求示例:
|
/// POST /api/MesItemBl/SplitBarcode
|
/// {
|
/// "billNo": "WO202401010001", // 工单号(必填)
|
/// "barcode": "BC001", // 条码号(必填)
|
/// "userName": "admin", // 用户名(必填)
|
/// "blNo": "BL202401010001", // 补料单号(必填)
|
/// "Num": 10 // 拆分数量(必填,必须大于0)
|
/// }
|
/// 业务处理:
|
/// - 验证补料单状态
|
/// - 验证条码库存信息
|
/// - 验证拆分数量是否合理
|
/// - 执行条码拆分事务处理
|
/// - 更新工单和补料单相关数量
|
/// 返回数据包含:
|
/// - success: 拆分是否成功
|
/// - pendingList: 待处理明细列表,包含:
|
/// * Bld012: 物料ID
|
/// * Bld002: 物料编号
|
/// * Bld003: 物料名称
|
/// * Bld004: 物料规格
|
/// * Bld007: 计划数量
|
/// * Bld008: 已补数量
|
/// </remarks>
|
/// <response code="200">拆分成功</response>
|
/// <response code="400">拆分失败,返回具体错误信息</response>
|
[HttpPost("SplitBarcode")]
|
public ResponseResult SplitBarcode([FromBody] WarehouseQuery query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
var (success, pendingList) = _manager.SplitBarcode(query);
|
resultInfos.success = success;
|
resultInfos.pendingList = pendingList;
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
#region 销售出库
|
|
/// <summary>
|
/// 获取生产补料单号列表
|
/// </summary>
|
/// <returns>补料单号列表</returns>
|
/// <response code="200">成功获取补料单号列表</response>
|
/// <response code="400">获取失败</response>
|
[HttpPost("GetFHTZBillNo")]
|
public ResponseResult GetFHTZBillNo(WarehouseQuery query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.GetFHTZBillNo(query);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 根据单号获取生产补料单明细
|
/// </summary>
|
/// <param name="query">查询参数,必须包含billNo</param>
|
/// <returns>补料单明细列表</returns>
|
/// <remarks>
|
/// 请求示例:
|
/// POST /api/MesItemBl/GetMesItemBlDetailByBillNo
|
/// {
|
/// "billNo": "BL202401010001"
|
/// }
|
/// </remarks>
|
/// <response code="200">成功获取补料单明细</response>
|
/// <response code="400">获取失败,可能是单据号不存在或已完成</response>
|
[HttpPost("GetMesItemFHTZetailByBillNo")]
|
public ResponseResult GetMesItemFHTZetailByBillNo(
|
[FromBody] WarehouseQuery query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.GetMesItemFHTZetailByBillNo(query);
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
/// <summary>
|
/// 扫描条码
|
/// </summary>
|
/// <param name="query">查询参数</param>
|
/// <returns>扫描结果和待处理列表</returns>
|
/// <remarks>
|
/// 请求示例:
|
/// POST /api/MesItemBl/SctlScanBarcode
|
/// {
|
/// "billNo": "WO202401010001",
|
/// "barcode": "1234567890",
|
/// "userName": "admin",
|
/// "blNo": "BL202401010001"
|
/// }
|
/// </remarks>
|
/// <response code="200">扫描成功</response>
|
/// <response code="400">扫描失败,返回具体错误信息</response>
|
[HttpPost("XSCKScanBarcode")]
|
public ResponseResult XSCKScanBarcode([FromBody] WarehouseQuery query)
|
{
|
try
|
{
|
dynamic resultInfos = new ExpandoObject();
|
resultInfos.tbBillList = _manager.XSCKScanBarcode(query);
|
if (resultInfos.tbBillList.result == "2")
|
{
|
return new ResponseResult
|
{
|
status = Convert.ToInt32(resultInfos.tbBillList.result),
|
message = resultInfos.tbBillList.strMsg,
|
data = resultInfos
|
};
|
}
|
return new ResponseResult
|
{
|
status = 0,
|
message = "OK",
|
data = resultInfos
|
};
|
}
|
catch (Exception ex)
|
{
|
return ResponseResult.ResponseError(ex);
|
}
|
}
|
|
#endregion
|
|
}
|