完整功能
This commit is contained in:
5
services/__init__.py
Normal file
5
services/__init__.py
Normal file
@ -0,0 +1,5 @@
|
||||
"""服务包"""
|
||||
from .task_service import TaskService
|
||||
from .monitoring_service import MonitoringService
|
||||
|
||||
__all__ = ['TaskService', 'MonitoringService']
|
||||
BIN
services/__pycache__/__init__.cpython-39.pyc
Normal file
BIN
services/__pycache__/__init__.cpython-39.pyc
Normal file
Binary file not shown.
BIN
services/__pycache__/monitoring_service.cpython-39.pyc
Normal file
BIN
services/__pycache__/monitoring_service.cpython-39.pyc
Normal file
Binary file not shown.
BIN
services/__pycache__/task_service.cpython-39.pyc
Normal file
BIN
services/__pycache__/task_service.cpython-39.pyc
Normal file
Binary file not shown.
228
services/monitoring_service.py
Normal file
228
services/monitoring_service.py
Normal file
@ -0,0 +1,228 @@
|
||||
|
||||
"""监控服务"""
|
||||
import time
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from database.access_db import AccessDB
|
||||
from database.sql_server import SQLServerDB
|
||||
from config.settings import ACCESS_DB_PATH, ACCESS_DB_PASSWORD, MONITOR_INTERVAL
|
||||
from tcp.server import TCPServer
|
||||
|
||||
class MonitoringService:
|
||||
def __init__(self, tcp_server):
|
||||
self.tcp_server = tcp_server
|
||||
self.task_flags = {}
|
||||
self.monitored_tasks = set()
|
||||
self.inserted_tasks = {}
|
||||
self.tasks_lock = threading.Lock()
|
||||
|
||||
def monitor_access_flag_changes(self):
|
||||
"""监控Access数据库中派发任务的Flag状态"""
|
||||
print("开始监控Access数据库中派发任务的Flag状态")
|
||||
|
||||
while True:
|
||||
try:
|
||||
# 每2秒检查一次
|
||||
time.sleep(MONITOR_INTERVAL)
|
||||
|
||||
with self.tasks_lock:
|
||||
# 如果没有需要监控的任务,跳过
|
||||
if not self.monitored_tasks:
|
||||
continue
|
||||
|
||||
# 创建需要监控的任务列表副本
|
||||
tasks_to_monitor = self.monitored_tasks.copy()
|
||||
|
||||
# 检查SQL Server中任务是否还存在
|
||||
sql_db = SQLServerDB()
|
||||
try:
|
||||
existing_tasks_in_sql = sql_db.check_existing_tasks(list(tasks_to_monitor))
|
||||
finally:
|
||||
sql_db.close()
|
||||
|
||||
# 分离已删除和未删除的任务
|
||||
erp_ids_str = [str(erp_id) for erp_id in tasks_to_monitor]
|
||||
deleted_from_sql_tasks = set(erp_ids_str) - existing_tasks_in_sql
|
||||
|
||||
print(f"SQL Server中仍存在的任务: {existing_tasks_in_sql}")
|
||||
print(f"已从SQL Server删除的任务: {deleted_from_sql_tasks}")
|
||||
|
||||
# 只有已从SQL Server删除的任务才需要在Access中查找
|
||||
if not deleted_from_sql_tasks:
|
||||
continue
|
||||
|
||||
# 查询Access数据库中已删除任务的状态
|
||||
access_db = AccessDB(ACCESS_DB_PATH, ACCESS_DB_PASSWORD)
|
||||
try:
|
||||
current_tasks = access_db.query_task_status(list(deleted_from_sql_tasks))
|
||||
finally:
|
||||
access_db.close()
|
||||
|
||||
# 处理任务状态变化
|
||||
self._process_task_status_changes(deleted_from_sql_tasks, current_tasks)
|
||||
|
||||
except Exception as e:
|
||||
print(f"监控Access数据库 Flag时发生错误: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
continue
|
||||
|
||||
def _process_task_status_changes(self, deleted_from_sql_tasks, current_tasks):
|
||||
"""处理任务状态变化"""
|
||||
# 检查每个已删除任务的状态变化
|
||||
for erp_id_str in deleted_from_sql_tasks:
|
||||
erp_id = int(erp_id_str)
|
||||
current_flag = current_tasks.get(erp_id_str, "")
|
||||
previous_flag = self.task_flags.get(erp_id_str, "")
|
||||
|
||||
# 添加调试信息
|
||||
print(f"检查任务 {erp_id} - 当前Flag: '{current_flag}', 之前Flag: '{previous_flag}'")
|
||||
|
||||
# 如果状态发生变化
|
||||
if current_flag != previous_flag:
|
||||
with self.tasks_lock:
|
||||
artifact_id = self.inserted_tasks.get(erp_id, "Unknown")
|
||||
print(
|
||||
f"派发任务 ErpID {erp_id} (ArtifactID: {artifact_id}) 的Flag值已更新: {previous_flag} -> {current_flag}")
|
||||
self.task_flags[erp_id_str] = current_flag
|
||||
|
||||
# 根据Flag值末尾的字母执行相应操作并更新自定义数据表状态
|
||||
self._handle_flag_status_change(erp_id, current_flag, artifact_id)
|
||||
|
||||
# 检查是否有任务记录已被删除(不在查询结果中但仍在监控列表中)
|
||||
# 这表示任务可能已完成或从系统中移除
|
||||
missing_tasks = set(deleted_from_sql_tasks) - set(current_tasks.keys())
|
||||
if missing_tasks:
|
||||
self._handle_missing_tasks(missing_tasks)
|
||||
|
||||
def _handle_flag_status_change(self, erp_id, current_flag, artifact_id):
|
||||
"""处理标志状态变化"""
|
||||
if current_flag.endswith('d'):
|
||||
self._handle_status_d(erp_id, artifact_id)
|
||||
elif current_flag.endswith('w'):
|
||||
self._handle_status_w(erp_id, artifact_id)
|
||||
elif current_flag.endswith('n'):
|
||||
self._handle_status_n(erp_id, artifact_id)
|
||||
elif current_flag.endswith('p'):
|
||||
self._handle_status_p(erp_id, artifact_id)
|
||||
elif current_flag.endswith('x'):
|
||||
self._handle_status_x(erp_id, artifact_id)
|
||||
|
||||
def _handle_status_d(self, erp_id, artifact_id):
|
||||
"""处理状态'd' - 未进行生产"""
|
||||
print(f"派发任务 ErpID {erp_id}: 未进行生产")
|
||||
# 调用同事提供的状态更新函数
|
||||
try:
|
||||
print(1)
|
||||
# update_custom_table_status(erp_id, "未进行生产")
|
||||
except Exception as e:
|
||||
print(f"更新状态时出错: {e}")
|
||||
|
||||
# 发送数据给TCP客户端(只发送erp_id和状态)
|
||||
try:
|
||||
status_data = {
|
||||
"erp_id": erp_id,
|
||||
"status": "未进行生产"
|
||||
}
|
||||
self.tcp_server.send_data(status_data)
|
||||
except Exception as e:
|
||||
print(f"发送状态数据给TCP客户端时出错: {e}")
|
||||
|
||||
def _handle_status_w(self, erp_id, artifact_id):
|
||||
"""处理状态'w' - 正在生产中"""
|
||||
print(f"派发任务 ErpID {erp_id}: 正在生产中")
|
||||
# 调用同事提供的状态更新函数
|
||||
try:
|
||||
print(2)
|
||||
# update_custom_table_status(erp_id, "正在生产中")
|
||||
except Exception as e:
|
||||
print(f"更新状态时出错: {e}")
|
||||
|
||||
# 发送数据给TCP客户端(只发送erp_id和状态)
|
||||
try:
|
||||
status_data = {
|
||||
"erp_id": erp_id,
|
||||
"status": "正在生产中"
|
||||
}
|
||||
self.tcp_server.send_data(status_data)
|
||||
except Exception as e:
|
||||
print(f"发送状态数据给TCP客户端时出错: {e}")
|
||||
|
||||
def _handle_status_n(self, erp_id, artifact_id):
|
||||
"""处理状态'n' - 生产完毕"""
|
||||
print(f"派发任务 ErpID {erp_id}: 生产完毕")
|
||||
# 任务完成,可以从监控列表中移除
|
||||
with self.tasks_lock:
|
||||
self.monitored_tasks.discard(erp_id)
|
||||
print(f"派发任务 ErpID {erp_id} 已完成,停止监控")
|
||||
# 调用同事提供的状态更新函数
|
||||
try:
|
||||
print(3)
|
||||
# update_custom_table_status(erp_id, "生产完毕")
|
||||
except Exception as e:
|
||||
print(f"更新状态时出错: {e}")
|
||||
|
||||
# 发送数据给TCP客户端(只发送erp_id和状态)
|
||||
try:
|
||||
status_data = {
|
||||
"erp_id": erp_id,
|
||||
"status": "生产完毕"
|
||||
}
|
||||
self.tcp_server.send_data(status_data)
|
||||
except Exception as e:
|
||||
print(f"发送状态数据给TCP客户端时出错: {e}")
|
||||
|
||||
def _handle_status_p(self, erp_id, artifact_id):
|
||||
"""处理状态'p' - 生产中断"""
|
||||
print(f"派发任务 ErpID {erp_id}: 生产中断")
|
||||
# 任务中断,可以从监控列表中移除
|
||||
with self.tasks_lock:
|
||||
self.monitored_tasks.discard(erp_id)
|
||||
print(f"派发任务 ErpID {erp_id} 已中断,停止监控")
|
||||
# 调用同事提供的状态更新函数
|
||||
try:
|
||||
print(4)
|
||||
# update_custom_table_status(erp_id, "生产中断")
|
||||
except Exception as e:
|
||||
print(f"更新状态时出错: {e}")
|
||||
|
||||
# 发送数据给TCP客户端(只发送erp_id和状态)
|
||||
try:
|
||||
status_data = {
|
||||
"erp_id": erp_id,
|
||||
"status": "生产中断"
|
||||
}
|
||||
self.tcp_server.send_data(status_data)
|
||||
except Exception as e:
|
||||
print(f"发送状态数据给TCP客户端时出错: {e}")
|
||||
|
||||
def _handle_status_x(self, erp_id, artifact_id):
|
||||
"""处理状态'x' - 数据已接收"""
|
||||
print(f"派发任务 ErpID {erp_id}: 数据已接收")
|
||||
# 调用同事提供的状态更新函数
|
||||
try:
|
||||
print(5)
|
||||
# update_custom_table_status(erp_id, "数据已接收")
|
||||
except Exception as e:
|
||||
print(f"更新状态时出错: {e}")
|
||||
|
||||
# 发送数据给TCP客户端(只发送erp_id和状态)
|
||||
try:
|
||||
status_data = {
|
||||
"erp_id": erp_id,
|
||||
"status": "数据已接收"
|
||||
}
|
||||
self.tcp_server.send_data(status_data)
|
||||
except Exception as e:
|
||||
print(f"发送状态数据给TCP客户端时出错: {e}")
|
||||
|
||||
def _handle_missing_tasks(self, missing_tasks):
|
||||
"""处理缺失的任务"""
|
||||
for erp_id_str in missing_tasks:
|
||||
erp_id = int(erp_id_str)
|
||||
with self.tasks_lock:
|
||||
artifact_id = self.inserted_tasks.get(erp_id, "Unknown")
|
||||
self.monitored_tasks.discard(erp_id)
|
||||
self.inserted_tasks.pop(erp_id, None)
|
||||
self.task_flags.pop(erp_id_str, None)
|
||||
print(f"派发任务 ErpID {erp_id} (ArtifactID: {artifact_id}) 记录已从Access数据库中删除或完成")
|
||||
303
services/task_service.py
Normal file
303
services/task_service.py
Normal file
@ -0,0 +1,303 @@
|
||||
"""任务处理服务"""
|
||||
from datetime import datetime
|
||||
from API.client import APIClient
|
||||
from database.access_db import AccessDB
|
||||
from database.sql_server import SQLServerDB
|
||||
from config.settings import ACCESS_DB_PATH, ACCESS_DB_PASSWORD
|
||||
from utils.helpers import get_f_block_positions
|
||||
|
||||
|
||||
class TaskService:
|
||||
def __init__(self):
|
||||
self.api_client = APIClient()
|
||||
self.half_volume = [0, 0]
|
||||
self.task_before = None
|
||||
self.artifact_timestamps = {}
|
||||
|
||||
def process_not_pour_info(self):
|
||||
"""处理未浇筑信息"""
|
||||
artifact_list = self.api_client.get_not_pour_info()
|
||||
|
||||
if not artifact_list:
|
||||
return [], [], [], self.half_volume
|
||||
|
||||
# 处理F块信息
|
||||
f_blocks_info = self._process_f_blocks(artifact_list)
|
||||
f_blocks = f_blocks_info["f_blocks"]
|
||||
f_block_count = f_blocks_info["f_block_count"]
|
||||
total_f_volume = f_blocks_info["total_f_volume"]
|
||||
f_positions = f_blocks_info["f_positions"]
|
||||
|
||||
# 处理当前任务
|
||||
current_task = self._process_current_task(artifact_list[0])
|
||||
|
||||
# 更新上一个任务信息
|
||||
self.task_before = {
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": current_task["beton_volume"],
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": current_task["block_number"]
|
||||
}
|
||||
|
||||
# 根据F块情况处理任务
|
||||
task_result = self._handle_tasks_by_f_blocks(
|
||||
f_block_count, f_positions, current_task,
|
||||
f_blocks, total_f_volume, artifact_list
|
||||
)
|
||||
|
||||
return task_result
|
||||
|
||||
def _process_f_blocks(self, artifact_list):
|
||||
"""处理F块相关信息"""
|
||||
f_blocks = [artifact for artifact in artifact_list if artifact.get("BlockNumber") == "F"]
|
||||
f_block_count = len(f_blocks)
|
||||
total_f_volume = sum(artifact["BetonVolume"] for artifact in f_blocks)
|
||||
f_positions = get_f_block_positions(artifact_list)
|
||||
|
||||
return {
|
||||
"f_blocks": f_blocks,
|
||||
"f_block_count": f_block_count,
|
||||
"total_f_volume": total_f_volume,
|
||||
"f_positions": f_positions
|
||||
}
|
||||
|
||||
def _process_current_task(self, latest_artifact):
|
||||
"""处理当前任务信息"""
|
||||
task_data = self.api_client.get_task_info(latest_artifact["BetonTaskID"])
|
||||
return {
|
||||
"beton_task_id": latest_artifact["BetonTaskID"],
|
||||
"beton_volume": latest_artifact["BetonVolume"],
|
||||
"artifact_id": latest_artifact["ArtifactActionID"],
|
||||
"block_number": latest_artifact.get("BlockNumber", ""),
|
||||
"task_data": task_data
|
||||
}
|
||||
|
||||
def _handle_tasks_by_f_blocks(self, f_block_count, f_positions, current_task,
|
||||
f_blocks, total_f_volume, artifact_list):
|
||||
"""根据F块数量和位置处理任务"""
|
||||
# 多个F块情况
|
||||
if f_block_count > 2:
|
||||
return self._handle_multiple_f_blocks(current_task, total_f_volume, artifact_list)
|
||||
|
||||
# 两个F块情况
|
||||
elif f_block_count == 2:
|
||||
return self._handle_two_f_blocks(f_positions, current_task, total_f_volume, artifact_list)
|
||||
|
||||
# 一个F块情况
|
||||
elif f_block_count == 1:
|
||||
return self._handle_single_f_block(f_positions, current_task, f_blocks,
|
||||
total_f_volume, artifact_list)
|
||||
|
||||
# 无F块情况
|
||||
elif f_block_count == 0:
|
||||
return self._handle_no_f_blocks(current_task, artifact_list)
|
||||
|
||||
else:
|
||||
print("报警")
|
||||
return [], [], [], self.half_volume
|
||||
|
||||
def _handle_multiple_f_blocks(self, current_task, total_f_volume, artifact_list):
|
||||
"""处理多个F块的情况"""
|
||||
adjusted_volume = total_f_volume - self.half_volume[0]
|
||||
|
||||
tasks = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": current_task["block_number"],
|
||||
}]
|
||||
|
||||
send_list = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": current_task["block_number"],
|
||||
"beton_grade": current_task["task_data"]["BetonGrade"],
|
||||
"mix_id": current_task["task_data"]["MixID"],
|
||||
"time": self.artifact_timestamps.get(current_task["artifact_id"], datetime.now())
|
||||
}]
|
||||
|
||||
# 处理后续任务
|
||||
self._append_additional_tasks(send_list, artifact_list, [0, 0])
|
||||
|
||||
# 更新时间戳
|
||||
self._update_artifact_timestamps(send_list)
|
||||
|
||||
return tasks, artifact_list, send_list, self.half_volume
|
||||
|
||||
def _handle_two_f_blocks(self, f_positions, current_task, total_f_volume, artifact_list):
|
||||
"""处理两个F块的情况"""
|
||||
if f_positions == [0, 1] and self.task_before.get("block_number") == "F":
|
||||
adjusted_volume = 0
|
||||
block_number = "补方"
|
||||
else:
|
||||
adjusted_volume = total_f_volume - self.half_volume[0]
|
||||
block_number = current_task["block_number"]
|
||||
|
||||
tasks = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": block_number,
|
||||
}]
|
||||
|
||||
send_list = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": block_number,
|
||||
"beton_grade": current_task["task_data"]["BetonGrade"],
|
||||
"mix_id": current_task["task_data"]["MixID"],
|
||||
"time": self.artifact_timestamps.get(current_task["artifact_id"], datetime.now())
|
||||
}]
|
||||
|
||||
# 处理后续任务
|
||||
volumes = [adjusted_volume,
|
||||
artifact_list[2]["BetonVolume"] if len(artifact_list) > 2 else 0] if f_positions == [0,
|
||||
1] and self.task_before.get(
|
||||
"block_number") == "F" else [0, 0]
|
||||
self._append_additional_tasks(send_list, artifact_list, volumes)
|
||||
|
||||
# 更新时间戳
|
||||
self._update_artifact_timestamps(send_list)
|
||||
|
||||
return tasks, artifact_list, send_list, self.half_volume
|
||||
|
||||
def _handle_single_f_block(self, f_positions, current_task, f_blocks, total_f_volume, artifact_list):
|
||||
"""处理单个F块的情况"""
|
||||
if f_positions == [2]:
|
||||
f_volume = f_blocks[0].get("BetonVolume") if f_blocks else 0
|
||||
self.half_volume[0] = round(total_f_volume / 2, 2)
|
||||
self.half_volume[1] = f_volume - self.half_volume[0]
|
||||
adjusted_volume = current_task["beton_volume"] + self.half_volume[0]
|
||||
elif f_positions == [1]:
|
||||
adjusted_volume = current_task["beton_volume"] + self.half_volume[1]
|
||||
elif f_positions == [0]:
|
||||
adjusted_volume = 0
|
||||
else:
|
||||
adjusted_volume = current_task["beton_volume"]
|
||||
|
||||
block_number = "补方" if f_positions == [0] else current_task["block_number"]
|
||||
|
||||
tasks = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": block_number,
|
||||
}]
|
||||
|
||||
send_list = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": adjusted_volume,
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": block_number,
|
||||
"beton_grade": current_task["task_data"]["BetonGrade"],
|
||||
"mix_id": current_task["task_data"]["MixID"],
|
||||
"time": self.artifact_timestamps.get(current_task["artifact_id"], datetime.now())
|
||||
}]
|
||||
|
||||
# 处理后续任务
|
||||
self._append_additional_tasks_for_single_f(send_list, artifact_list, f_positions)
|
||||
|
||||
# 更新时间戳
|
||||
self._update_artifact_timestamps(send_list)
|
||||
|
||||
return tasks, artifact_list, send_list, self.half_volume
|
||||
|
||||
def _handle_no_f_blocks(self, current_task, artifact_list):
|
||||
"""处理无F块的情况"""
|
||||
tasks = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": current_task["beton_volume"],
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": current_task["block_number"],
|
||||
}]
|
||||
|
||||
send_list = [{
|
||||
"beton_task_id": current_task["beton_task_id"],
|
||||
"beton_volume": current_task["beton_volume"],
|
||||
"artifact_id": current_task["artifact_id"],
|
||||
"block_number": current_task["block_number"],
|
||||
"beton_grade": current_task["task_data"]["BetonGrade"],
|
||||
"mix_id": current_task["task_data"]["MixID"],
|
||||
"time": self.artifact_timestamps.get(current_task["artifact_id"], datetime.now())
|
||||
}]
|
||||
|
||||
# 处理后续任务
|
||||
self._append_additional_tasks(send_list, artifact_list,
|
||||
[artifact_list[2]["BetonVolume"] if len(artifact_list) > 2 else 0,
|
||||
artifact_list[2]["BetonVolume"] if len(artifact_list) > 2 else 0])
|
||||
|
||||
# 更新时间戳
|
||||
self._update_artifact_timestamps(send_list)
|
||||
|
||||
return tasks, artifact_list, send_list, self.half_volume
|
||||
|
||||
def _append_additional_tasks(self, send_list, artifact_list, volumes):
|
||||
"""添加额外的任务到发送列表"""
|
||||
# 安全获取后续任务
|
||||
second_task = artifact_list[1] if len(artifact_list) > 1 else None
|
||||
third_task = artifact_list[2] if len(artifact_list) > 2 else None
|
||||
|
||||
if second_task:
|
||||
task_data_second = self.api_client.get_task_info(second_task["BetonTaskID"])
|
||||
send_list.append({
|
||||
"beton_task_id": second_task["BetonTaskID"],
|
||||
"beton_volume": volumes[0],
|
||||
"artifact_id": second_task["ArtifactActionID"],
|
||||
"block_number": second_task["BlockNumber"],
|
||||
"beton_grade": task_data_second["BetonGrade"],
|
||||
"mix_id": task_data_second["MixID"],
|
||||
"time": self.artifact_timestamps.get(second_task["ArtifactActionID"], datetime.now())
|
||||
})
|
||||
|
||||
if third_task:
|
||||
task_data_third = self.api_client.get_task_info(third_task["BetonTaskID"])
|
||||
send_list.append({
|
||||
"beton_task_id": third_task["BetonTaskID"],
|
||||
"beton_volume": volumes[1],
|
||||
"artifact_id": third_task["ArtifactActionID"],
|
||||
"block_number": third_task["BlockNumber"],
|
||||
"beton_grade": task_data_third["BetonGrade"],
|
||||
"mix_id": task_data_third["MixID"],
|
||||
"time": self.artifact_timestamps.get(third_task["ArtifactActionID"], datetime.now())
|
||||
})
|
||||
|
||||
def _append_additional_tasks_for_single_f(self, send_list, artifact_list, f_positions):
|
||||
"""为单个F块情况添加额外任务"""
|
||||
second_task = artifact_list[1] if len(artifact_list) > 1 else None
|
||||
third_task = artifact_list[2] if len(artifact_list) > 2 else None
|
||||
|
||||
if second_task:
|
||||
task_data_second = self.api_client.get_task_info(second_task["BetonTaskID"])
|
||||
volume = (third_task["BetonVolume"] if third_task else 0) if f_positions != [2] else (
|
||||
second_task["BetonVolume"] + self.half_volume[1])
|
||||
send_list.append({
|
||||
"beton_task_id": second_task["BetonTaskID"],
|
||||
"beton_volume": volume,
|
||||
"artifact_id": second_task["ArtifactActionID"],
|
||||
"block_number": second_task["BlockNumber"],
|
||||
"beton_grade": task_data_second["BetonGrade"],
|
||||
"mix_id": task_data_second["MixID"],
|
||||
"time": self.artifact_timestamps.get(second_task["ArtifactActionID"], datetime.now())
|
||||
})
|
||||
|
||||
if third_task:
|
||||
task_data_third = self.api_client.get_task_info(third_task["BetonTaskID"])
|
||||
volume = third_task["BetonVolume"] if f_positions in [[1], [0]] else 0
|
||||
send_list.append({
|
||||
"beton_task_id": third_task["BetonTaskID"],
|
||||
"beton_volume": volume,
|
||||
"artifact_id": third_task["ArtifactActionID"],
|
||||
"block_number": third_task["BlockNumber"],
|
||||
"beton_grade": task_data_third["BetonGrade"],
|
||||
"mix_id": task_data_third["MixID"],
|
||||
"time": self.artifact_timestamps.get(third_task["ArtifactActionID"], datetime.now())
|
||||
})
|
||||
|
||||
def _update_artifact_timestamps(self, send_list):
|
||||
"""更新artifact时间戳"""
|
||||
current_artifact_ids = {item["artifact_id"] for item in send_list}
|
||||
for artifact_id in current_artifact_ids:
|
||||
if artifact_id not in self.artifact_timestamps:
|
||||
self.artifact_timestamps[artifact_id] = datetime.now()
|
||||
Reference in New Issue
Block a user