变频器集成以及增加点动控制(0209)
This commit is contained in:
@ -58,7 +58,7 @@ class BaseHttpClient:
|
||||
# 解析JSON响应
|
||||
return response.json()
|
||||
|
||||
except exception as e:
|
||||
except Exception as e:
|
||||
# 如果是最后一次尝试,直接抛出异常
|
||||
if attempt == retries:
|
||||
print(f"请求失败(第{attempt + 1}次尝试): {e}")
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from common.sqlite_handler import SQLiteHandler
|
||||
from typing import Optional, List
|
||||
@ -42,7 +46,16 @@ class MouldService:
|
||||
return None
|
||||
|
||||
# 转换为任务单信息对象
|
||||
task_info = TaskInfo(**data)
|
||||
task_info = TaskInfo(
|
||||
TaskID=data.get('TaskID', ''),
|
||||
TaskStatus=data.get('TaskStatus', 0),
|
||||
TaskStatusText=data.get('TaskStatusText', ''),
|
||||
ProjectName=data.get('ProjectName', ''),
|
||||
BetonGrade=data.get('BetonGrade', ''),
|
||||
MixID=data.get('MixID', ''),
|
||||
ProduceMixID=data.get('ProduceMixID', ''),
|
||||
PlannedVolume=data.get('PlannedVolume', 0.0)
|
||||
)
|
||||
return task_info
|
||||
|
||||
except Exception as e:
|
||||
@ -51,12 +64,12 @@ class MouldService:
|
||||
|
||||
def get_not_pour_artifacts(self) -> Optional[List[ArtifactInfo]]:
|
||||
"""
|
||||
获取已入模绑定未浇筑的管片信息
|
||||
获取已入待浇筑的管片信息
|
||||
|
||||
Returns:
|
||||
未浇筑管片列表,如果失败返回None
|
||||
"""
|
||||
url = f"{self._host}/api/ext/mould/not_pour_hidden"
|
||||
url = f"{self._host}/api/ext/mould/not_pour_rfid"
|
||||
|
||||
try:
|
||||
# 调用API获取数据
|
||||
@ -74,7 +87,8 @@ class MouldService:
|
||||
return []
|
||||
|
||||
# 转换为管片信息对象列表
|
||||
artifacts = [ArtifactInfo(**item) for item in data_list]
|
||||
# artifacts = [ArtifactInfo(**item) for item in data_list]
|
||||
artifacts = [ArtifactInfo(**item) for item in data_list if item.get('MouldCode') is not None and item.get('MouldCode') != '']
|
||||
return artifacts
|
||||
|
||||
except Exception as e:
|
||||
@ -136,60 +150,62 @@ class MouldService:
|
||||
|
||||
app_web_service = MouldService()
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# # 创建模具服务实例
|
||||
# mould_service = MouldService()
|
||||
# led_info = mould_service.get_pouring_led()
|
||||
# if led_info:
|
||||
# print(led_info)
|
||||
if __name__ == "__main__":
|
||||
# 创建模具服务实例
|
||||
mould_service = MouldService()
|
||||
# led_info = mould_service.get_pouring_led()
|
||||
# if led_info:
|
||||
# print(led_info)
|
||||
|
||||
# db = SQLiteHandler.get_instance("db/three.db", max_readers=50, busy_timeout=4000)
|
||||
db = SQLiteHandler.get_instance("db/three.db", max_readers=50, busy_timeout=4000)
|
||||
# 测试获取未浇筑管片信息
|
||||
# not_poured = mould_service.get_not_pour_artifacts()
|
||||
# if not_poured:
|
||||
# for item in not_poured:
|
||||
# artifact = db.fetch_one("SELECT * FROM ArtifactTask WHERE ArtifactID = ?", (item.ArtifactID,))
|
||||
# if not artifact:
|
||||
# dict={
|
||||
# "ArtifactID": item.ArtifactID,
|
||||
# "ArtifactActionID": item.ArtifactActionID,
|
||||
# "ArtifactIDVice1": item.ArtifactIDVice1,
|
||||
# "ProduceRingNumber": item.ProduceRingNumber,
|
||||
# "MouldCode": item.MouldCode,
|
||||
# "SkeletonID": item.SkeletonID,
|
||||
# "RingTypeCode": item.RingTypeCode,
|
||||
# "SizeSpecification": item.SizeSpecification,
|
||||
# "BuriedDepth": item.BuriedDepth,
|
||||
# "BlockNumber": item.BlockNumber,
|
||||
# "BetonVolume": item.BetonVolume,
|
||||
# "BetonTaskID": item.BetonTaskID,
|
||||
# "HoleRingMarking": item.HoleRingMarking,
|
||||
# "GroutingPipeMarking": item.GroutingPipeMarking,
|
||||
# "PolypropyleneFiberMarking": item.PolypropyleneFiberMarking,
|
||||
# "Status": 1,
|
||||
# "Source": 1
|
||||
# }
|
||||
# db.insert("ArtifactTask", dict)
|
||||
not_poured = mould_service.get_not_pour_artifacts()
|
||||
if not_poured:
|
||||
for item in not_poured:
|
||||
artifact = db.fetch_one("SELECT * FROM ArtifactTask WHERE ArtifactID = ?", (item.ArtifactID,))
|
||||
if not artifact:
|
||||
dict={
|
||||
"ArtifactID": item.ArtifactID,
|
||||
"ArtifactActionID": item.ArtifactActionID,
|
||||
"ArtifactIDVice1": item.ArtifactIDVice1,
|
||||
"ProduceRingNumber": item.ProduceRingNumber,
|
||||
"MouldCode": item.MouldCode,
|
||||
"SkeletonID": item.SkeletonID,
|
||||
"RingTypeCode": item.RingTypeCode,
|
||||
"SizeSpecification": item.SizeSpecification,
|
||||
"BuriedDepth": item.BuriedDepth,
|
||||
"BlockNumber": item.BlockNumber,
|
||||
"BetonVolume": item.BetonVolume,
|
||||
"BetonTaskID": item.BetonTaskID,
|
||||
"HoleRingMarking": item.HoleRingMarking,
|
||||
"GroutingPipeMarking": item.GroutingPipeMarking,
|
||||
"PolypropyleneFiberMarking": item.PolypropyleneFiberMarking,
|
||||
"Status": 1,
|
||||
"Source": 1
|
||||
}
|
||||
db.insert("ArtifactTask", dict)
|
||||
|
||||
# dict={
|
||||
# "TaskID": item.BetonTaskID,
|
||||
# "ProjectName": "上海市轨道交通19号线工程盾构区间管片生产2标",
|
||||
# "ProduceMixID": "20251030-02",
|
||||
# "VinNo": "",
|
||||
# "BetonVolume": item.BetonVolume,
|
||||
# "MouldCode": item.MouldCode,
|
||||
# "SkeletonID": item.SkeletonID,
|
||||
# "RingTypeCode": item.RingTypeCode,
|
||||
# "SizeSpecification": item.SizeSpecification,
|
||||
# "BuriedDepth": item.BuriedDepth,
|
||||
# "BlockNumber": item.BlockNumber,
|
||||
# "Mode": 1,
|
||||
# "Status": 1,
|
||||
# "Source": 1,
|
||||
# "OptTime": str(datetime.now() - timedelta(minutes=5)),
|
||||
# "CreateTime": str(datetime.now())
|
||||
# }
|
||||
# db.insert("PDRecord", dict)
|
||||
dict={
|
||||
"TaskID": item.BetonTaskID,
|
||||
"ProjectName": "上海市轨道交通19号线工程盾构区间管片生产2标",
|
||||
"ProduceMixID": "20251030-02",
|
||||
"VinNo": "",
|
||||
"BetonVolume": item.BetonVolume,
|
||||
"MouldCode": item.MouldCode,
|
||||
"SkeletonID": item.SkeletonID,
|
||||
"RingTypeCode": item.RingTypeCode,
|
||||
"SizeSpecification": item.SizeSpecification,
|
||||
"BuriedDepth": item.BuriedDepth,
|
||||
"BlockNumber": item.BlockNumber,
|
||||
"Mode": 1,
|
||||
"Status": 1,
|
||||
"Source": 1,
|
||||
"OptTime": str(datetime.now() - timedelta(minutes=5)),
|
||||
"CreateTime": str(datetime.now())
|
||||
}
|
||||
db.insert("PDRecord", dict)
|
||||
|
||||
|
||||
# for i in range(2, 5):
|
||||
# row = db.fetch_one("SELECT * FROM ArtifactTask WHERE ID = ?", (i,))
|
||||
# if row:
|
||||
|
||||
Reference in New Issue
Block a user