feat: implement dynamic inspection requirement logic based on material master data
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# 文件路径: app/api/v1/inbound/base.py
|
||||
|
||||
from flask import Blueprint, request, jsonify, send_file, g
|
||||
from flask import Blueprint, request, jsonify, send_file, g, current_app
|
||||
from app.extensions import db
|
||||
from app.services.inbound.base_service import MaterialBaseService
|
||||
from app.utils.decorators import login_required, permission_required, audit_log
|
||||
@ -410,3 +410,49 @@ def batch_set_warning():
|
||||
db.session.rollback()
|
||||
current_app.logger.error(f"批量设置预警失败: {str(e)}")
|
||||
return jsonify({"code": 500, "msg": f"批量设置预警失败: {str(e)}"}), 500
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# 2.6 批量设置强制质检 API (POST /api/v1/inbound/base/batch-inspection)
|
||||
# ==============================================================================
|
||||
@inbound_base_bp.route('/batch-inspection', methods=['POST'])
|
||||
@permission_required('material_list:operation')
|
||||
def batch_set_inspection():
|
||||
"""
|
||||
批量设置物料强制质检标记
|
||||
请求体格式: {
|
||||
"ids": [1, 2, 3],
|
||||
"isInspectionRequired": true
|
||||
}
|
||||
"""
|
||||
try:
|
||||
data = request.get_json()
|
||||
if not data:
|
||||
return jsonify({"code": 400, "msg": "No data provided"}), 400
|
||||
|
||||
ids = data.get('ids', [])
|
||||
is_inspection_required = bool(data.get('isInspectionRequired', False))
|
||||
|
||||
if not ids:
|
||||
return jsonify({"code": 400, "msg": "请选择要设置的物料"}), 400
|
||||
|
||||
updated_count = 0
|
||||
for base_id in ids:
|
||||
material = MaterialBase.query.get(base_id)
|
||||
if material:
|
||||
material.is_inspection_required = is_inspection_required
|
||||
updated_count += 1
|
||||
|
||||
db.session.commit()
|
||||
return jsonify({
|
||||
"code": 200,
|
||||
"msg": f"批量设置成功,已更新 {updated_count} 条记录",
|
||||
"data": {
|
||||
"updated": updated_count
|
||||
}
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
current_app.logger.error(f"批量设置强制质检失败: {str(e)}")
|
||||
return jsonify({"code": 500, "msg": f"批量设置强制质检失败: {str(e)}"}), 500
|
||||
|
||||
Reference in New Issue
Block a user