扫码枪出库接口

This commit is contained in:
2025-07-31 11:18:01 +08:00
parent b063ccefd4
commit e944fa1ae9
3 changed files with 32 additions and 0 deletions

View File

@@ -163,4 +163,13 @@ public class WmsStockIoController extends BaseController {
return R.fail(e.getMessage());
}
}
@PostMapping("/scanOutStock")
public R<Void> scanOutStock(@RequestBody WmsStockIoDetailBo bo) {
try {
boolean result = iWmsStockIoService.scanOutStockByBo(bo);
return toAjax(result);
} catch (Exception e) {
return R.fail(e.getMessage());
}
}
}

View File

@@ -77,4 +77,6 @@ public interface IWmsStockIoService {
boolean scanInStockByBo(WmsStockIoDetailBo bo);
boolean scanOutStockByBo(WmsStockIoDetailBo bo);
}

View File

@@ -162,6 +162,27 @@ public class WmsStockIoServiceImpl implements IWmsStockIoService {
changeStock(bo.getWarehouseId(), bo.getItemType(), bo.getItemId(), bo.getQuantity(), true, unit);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public boolean scanOutStockByBo(WmsStockIoDetailBo bo) {
String unit = bo.getUnit();
// 如果unit为空自动查item表补全
if (unit == null || unit.trim().isEmpty()) {
if ("product".equals(bo.getItemType())) {
WmsProduct p = productMapper.selectById(bo.getItemId());
unit = p != null ? p.getUnit() : null;
} else if ("raw_material".equals(bo.getItemType())) {
WmsRawMaterial r = rawMaterialMapper.selectById(bo.getItemId());
unit = r != null ? r.getUnit() : null;
}
}
if (unit == null || unit.trim().isEmpty()) {
throw new RuntimeException("未能获取到单位");
}
// 出库操作
changeStock(bo.getWarehouseId(), bo.getItemType(), bo.getItemId(), bo.getQuantity(), false, unit);
return true;
}
/**