对于半成品的条形码进行更改

This commit is contained in:
dxc
2026-02-03 09:01:03 +08:00
parent 11a4e5f48a
commit 98450d73f1
4 changed files with 238 additions and 109 deletions

View File

@ -1,8 +1,9 @@
# inventory-backend/app/api/v1/inbound/semi.py
from flask import Blueprint, request, jsonify
from app.services.inbound.semi_service import SemiInboundService
import traceback
# 定义蓝图url_prefix 通常在注册蓝图时指定,例如 /api/v1/inbound/semi
# 定义蓝图
inbound_semi_bp = Blueprint('inbound_semi', __name__)
@ -48,7 +49,7 @@ def get_list():
# ------------------------------------------------------------------
# 2. 新增半成品入库
# 2. 新增半成品入库 (修改:返回创建的对象数据)
# ------------------------------------------------------------------
@inbound_semi_bp.route('/submit', methods=['POST'])
def submit():
@ -57,8 +58,15 @@ def submit():
if not data:
return jsonify({"code": 400, "msg": "No data"}), 400
SemiInboundService.handle_inbound(data)
return jsonify({"code": 200, "msg": "入库成功"})
# 修改:调用 Service 处理入库,获取新创建的对象
new_stock = SemiInboundService.handle_inbound(data)
# 修改返回成功信息以及新创建的数据包含生成的ID和SKU供前端打印使用
return jsonify({
"code": 200,
"msg": "入库成功",
"data": new_stock.to_dict()
})
except Exception as e:
traceback.print_exc()
return jsonify({"code": 500, "msg": str(e)}), 500