using System.Dynamic; using Microsoft.AspNetCore.Mvc; using NewPdaSqlServer.Dto.service; using NewPdaSqlServer.service.@base; using NewPdaSqlServer.service.Warehouse; using NewPdaSqlServer.util; namespace NewPdaSqlServer.Controllers.Warehouse; /// /// 调拨出库相关接口 /// [Route("api/[controller]")] [ApiController] public class TransferOutController : ControllerBase { private readonly TransferOutManager _manager = new(); private readonly MesPrintMangeer _mCf = 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); } } #endregion #region 调拨入库业务 /// /// 扫描条码进行调拨入库处理 /// /// 查询参数 /// 处理结果和待处理明细 /// /// 请求示例: /// POST /api/TransferOut/ScanReceiveBarcode /// { /// "billNo": "DB202401010001", // 调拨单号(必填) /// "userName": "admin", // 用户名(必填) /// "barcode": "BC001" // 条码号(必填) /// } /// 业务处理: /// - 验证调拨单状态 /// - 验证条码库存信息 /// - 验证仓库一致性 /// - 验证数量是否超出未扫数量 /// - 执行调拨入库事务处理 /// 返回数据包含: /// - form: 处理结果表单 /// - items: 待处理明细列表 /// /// 扫描成功 /// 扫描失败,返回具体错误信息 [HttpPost("ScanReceiveBarcode")] public ResponseResult ScanReceiveBarcode([FromBody] WarehouseQuery query) { try { dynamic resultInfos = new ExpandoObject(); var (form, items) = _manager.ScanReceiveBarcode(query); resultInfos.form = form; resultInfos.items = items; return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } #endregion #region 调拨出库业务 /// /// 获取未完成的调拨出库单号列表 /// /// 未完成的调拨出库单号列表 /// /// 获取申请数量(sq)不等于已扫数量(ys)的调拨出库单号列表 /// /// 成功获取调拨出库单号列表 /// 获取失败 [HttpPost("GetTransferOutNoList")] public ResponseResult GetTransferOutNoList() { try { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = _manager.GetTransferOutNoList(); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } /// /// 根据单据号获取待处理的调拨出库明细列表 /// /// 查询参数 /// 待处理的调拨出库明细列表 /// /// 请求示例: /// POST /api/TransferOut/GetTransferOutDetailListByBillNo /// { /// "billNo": "DB202401010001" // 调拨单号(必填) /// } /// 返回未完成的明细记录(ShNum-YsNum>0),包含: /// - ItemNo: 物料编号 /// - ItemModel: 物料规格 /// - ShNum: 申请数量 /// - YsNum: 已扫数量 /// /// 成功获取调拨出库明细 /// 获取失败,返回具体错误信息 [HttpPost("GetTransferOutDetailListByBillNo")] public ResponseResult GetTransferOutDetailListByBillNo( [FromBody] WarehouseQuery query) { try { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = _manager.GetTransferOutDetailListByBillNo(query); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } [HttpPost("GetTransferInDetailListByBillNo")] public ResponseResult GetTransferInDetailListByBillNo( [FromBody] WarehouseQuery query) { try { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = _manager.GetTransferInDetailListByBillNo(query); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } /// /// 扫描条码进行调拨出库处理 /// /// 查询参数 /// 处理结果和待处理明细 /// /// 请求示例: /// POST /api/TransferOut/ScanMoveBarcode /// { /// "billNo": "DB202401010001", // 调拨单号(必填) /// "userName": "admin", // 用户名(必填) /// "barcode": "BC001" // 条码号(必填) /// } /// 业务处理: /// - 验证调拨单状态 /// - 验证条码库存信息 /// - 验证仓库一致性 /// - 验证数量是否超出未扫数量 /// - 执行调拨出库事务处理 /// 返回数据包含: /// - form: 处理结果表单 /// - items: 待处理明细列表 /// /// 扫描成功 /// 扫描失败,返回具体错误信息 [HttpPost("ScanMoveBarcode")] public ResponseResult ScanMoveBarcode([FromBody] WarehouseQuery query) { try { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = _manager.ScanMoveBarcode(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); } } /// /// 分割条码进行调拨出库处理 /// /// 查询参数 /// 处理结果和待处理明细 /// /// 请求示例: /// POST /api/TransferOut/SplitBarcode /// { /// "billNo": "DB202401010001", // 调拨单号(必填) /// "userName": "admin", // 用户名(必填) /// "barcode": "BC001" // 条码号(必填) /// "fum": "1" // 拆分数(必填) /// } /// 业务处理: /// - 验证调拨单状态 /// - 验证条码库存信息 /// - 验证仓库一致性 /// - 验证数量是否超出未扫数量 /// - 执行分割条码的调拨出库事务处理 /// /// 分割成功 /// 分割失败,返回具体错误信息 [HttpPost("ScanCodeCF")] public ResponseResult ScanCodeCF(WarehouseQuery query) { try { dynamic resultInfos = new ExpandoObject(); resultInfos.tbBillList = new ExpandoObject(); resultInfos.tbBillList.printInfo = _mCf.getPrintInfo(query); var scanResult = _manager.ScanCodeCF(query); resultInfos.tbBillList.cfBarInfo = _mCf.getCfInfo(scanResult); return new ResponseResult { status = 0, message = "OK", data = resultInfos }; } catch (Exception ex) { return ResponseResult.ResponseError(ex); } } #endregion }