完整功能

This commit is contained in:
xiongyi
2025-11-12 14:01:26 +08:00
parent 084cf0ac52
commit 036fb08634
49 changed files with 2706 additions and 2121 deletions

273
API/send_data_test.py Normal file
View File

@ -0,0 +1,273 @@
from flask import Flask, request, jsonify
import json
from datetime import datetime
from datetime import timedelta
app = Flask(__name__)
@app.route('/api/user/perlogin', methods=['POST'])
def login():
"""
模拟登录接口 - 获取AppID
"""
try:
# 获取请求参数
data = request.get_json()
# 验证必要参数
if not all(k in data for k in ['Program', 'SC', 'loginName', 'password']):
return jsonify({
"Code": 400,
"Message": "缺少必要参数",
"Data": None
}), 400
# 模拟验证逻辑
expected_login_name = "leduser"
expected_password = "bfcda35cf4eba92d4583931bbe4ff72ffdfa8b5c9c4b72611bd33f5babee069d"
if data['loginName'] != expected_login_name or data['password'] != expected_password:
return jsonify({
"Code": 401,
"Message": "用户名或密码错误",
"Data": None
}), 401
# 模拟生成AppID和SignToken
app_id = "e00412005f74144a8654d24f9d4b4e5"
sign_token = "79a5c0da-ebfd-4ce3-832d-36c807cc0398"
expire_time = (datetime.now().replace(microsecond=0) + timedelta(hours=24)).isoformat()
response_data = {
"Code": 200,
"Message": None,
"Data": {
"AppID": app_id,
"SignToken": sign_token,
"ExpireTime": expire_time,
"ZrJwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI3OQ" # 简化JWT
}
}
return jsonify(response_data), 200
except Exception as e:
return jsonify({
"Code": 500,
"Message": f"服务器内部错误: {str(e)}",
"Data": None
}), 500
@app.route('/api/ext/mould/last_artifact', methods=['GET'])
def get_mould_info():
"""
模拟获取模具管片信息接口
"""
try:
# 获取查询参数
mould_code = request.args.get('mouldCode')
if not mould_code:
return jsonify({
"Code": 400,
"Message": "缺少mouldCode参数",
"Data": None
}), 400
# 模拟AppID验证这里简化处理
app_id = request.headers.get('AppID')
if not app_id:
return jsonify({
"Code": 401,
"Message": "缺少AppID认证",
"Data": None
}), 401
# 模拟返回数据
response_data = {
"Code": 200,
"Message": None,
"Data": {
"ArtifactID": "QR1B12000151AD",
"ArtifactActionID": 346482967298117,
"ArtifactIDVice1": "Q00001AD",
"ProduceRingNumber": 1,
"MouldCode": mould_code,
"SkeletonID": "QR1B12000046A",
"RingTypeCode": "R22",
"SizeSpecification": "6900*1500",
"BuriedDepth": "中埋",
"BlockNumber": "B1",
"HoleRingMarking": "",
"GroutingPipeMarking": "",
"PolypropyleneFiberMarking": "",
"BetonVolume": 6455.0000,
"BetonTaskID": "20251020-01"
}
}
return jsonify(response_data), 200
except Exception as e:
return jsonify({
"Code": 500,
"Message": f"服务器内部错误: {str(e)}",
"Data": None
}), 500
@app.route('/api/ext/artifact/task', methods=['GET'])
def get_task_info():
"""
模拟获取任务单信息接口
"""
try:
# 获取查询参数
task_id = request.args.get('TaskId')
if not task_id:
return jsonify({
"Code": 400,
"Message": "缺少TaskId参数",
"Data": None
}), 400
# 模拟AppID验证
app_id = request.headers.get('AppID')
if not app_id:
return jsonify({
"Code": 401,
"Message": "缺少AppID认证",
"Data": None
}), 401
# 模拟返回数据
response_data = {
"Code": 200,
"Message": None,
"Data": {
"TaskID": task_id,
"TaskStatus": 4,
"TaskStatusText": "已制单",
"TaskCount": 600,
"AlreadyProduceCount": 100,
"Progress": "100 / 600",
"ProjectName": "测试新增工程测试",
"TaskPlanDateText": "2025-07-18",
"BetonGrade": "C50",
"MixID": "P20250717001",
"ProduceMixID": "HNT-2025-07-17-001",
"PlannedVolume": 1050.00,
"ProducedVolume": 0.00,
"HoleRingMarking": "咕发环",
"GroutingPipeMarking": "",
"PolypropyleneFiberMarking": "",
"TaskDate": "1900-01-01T00:00:00",
"TaskDateText": "1900-01-01",
"PlateCount": 0,
"SendStatus": 0,
"SendStatusText": "未下发",
"MixSendStatus": 0,
"MixSendStatusText": "未下发"
}
}
return jsonify(response_data), 200
except Exception as e:
return jsonify({
"Code": 500,
"Message": f"服务器内部错误: {str(e)}",
"Data": None
}), 500
@app.route('/api/ext/artifact/not_pour', methods=['GET'])
def get_not_pour_info():
"""
模拟获取已入模绑定未浇筑的管片信息接口
"""
try:
# 模拟AppID验证
app_id = request.headers.get('AppID')
if not app_id:
return jsonify({
"Code": 401,
"Message": "缺少AppID认证",
"Data": None
}), 401
# 模拟返回多个记录
response_data = {
"Code": 200,
"Message": None,
"Data": [
{
"ArtifactID": "QR1B12000151AD",
"ArtifactActionID": 346482967298117,
"ArtifactIDVice1": "Q00001AD",
"ProduceRingNumber": 1,
"MouldCode": "SHR2B1-9",
"SkeletonID": "QR1B12000046A",
"RingTypeCode": "R22",
"SizeSpecification": "6900*1500",
"BuriedDepth": "中埋",
"BlockNumber": "B1",
"HoleRingMarking": "",
"GroutingPipeMarking": "",
"PolypropyleneFiberMarking": "",
"BetonVolume": 2.0000,
"BetonTaskID": "20251020-01"
},
{
"ArtifactID": "QR1B32000153AD",
"ArtifactActionID": 346482967298119,
"ArtifactIDVice1": "Q00001AD",
"ProduceRingNumber": 1,
"MouldCode": "SHR2B3-9",
"SkeletonID": "QR1B2000048A",
"RingTypeCode": "R22",
"SizeSpecification": "6900*1500",
"BuriedDepth": "中埋",
"BlockNumber": "B2",
"HoleRingMarking": "",
"GroutingPipeMarking": "",
"PolypropyleneFiberMarking": "",
"BetonVolume": 2.0000,
"BetonTaskID": "20251020-01"
},
{
"ArtifactID": "QR1B12000151AD",
"ArtifactActionID": 346482967298120,
"ArtifactIDVice1": "Q00001AD",
"ProduceRingNumber": 1,
"MouldCode": "SHR2B1-9",
"SkeletonID": "QR1B12000046A",
"RingTypeCode": "R22",
"SizeSpecification": "6900*1500",
"BuriedDepth": "中埋",
"BlockNumber": "B3",
"HoleRingMarking": "",
"GroutingPipeMarking": "",
"PolypropyleneFiberMarking": "",
"BetonVolume": 2.0000,
"BetonTaskID": "20251020-01"
},
]
}
return jsonify(response_data), 200
except Exception as e:
return jsonify({
"Code": 500,
"Message": f"服务器内部错误: {str(e)}",
"Data": None
}), 500
if __name__ == '__main__':
app.run(host='127.0.0.1', port=5000, debug=True)