|
@@ -330,7 +330,7 @@ class BatchDeleteDeviceApi(Resource):
|
|
|
|
|
|
|
|
|
import_device = reqparse.RequestParser(bundle_errors=True)
|
|
|
-import_device.add_argument(name='files', type=FileStorage, required=True, location='files', help='导入设备Excel')
|
|
|
+import_device.add_argument(name='files', type=FileStorage, required=True, location='files', help='导入设备xls文件')
|
|
|
import_device.add_argument(name='group_id', type=str, required=True, location='form', help='设备类别id')
|
|
|
|
|
|
|
|
@@ -368,6 +368,13 @@ class ImportDeviceApi(Resource):
|
|
|
device_file = request.files.get('files')
|
|
|
device_group_id = request.form.get('group_id')
|
|
|
|
|
|
+ if os.path.splitext(device_file.name)[-1] != '.xls':
|
|
|
+ return jsonify(code=StatesCode.PARA_ERROR, message='不支持的文件格式,仅支持 .xls 文件')
|
|
|
+
|
|
|
+ if device_group_id is None:
|
|
|
+ return jsonify(code=StatesCode.PARA_ERROR, message='设备类型id不能为空')
|
|
|
+
|
|
|
+
|
|
|
xlsx = xlrd.open_workbook(file_contents=device_file.read())
|
|
|
|
|
|
with Session(current_app.engine) as session:
|