删除 _fix_taskid.py

This commit is contained in:
2026-08-25 03:43:14 +00:00
parent 43fbd0af19
commit e9532ddafa

View File

@@ -1,75 +0,0 @@
# -*- coding: utf-8 -*-
import sys
path = r'C:\Users\jsmbz\Documents\flutter-app-02\lib\features\home\presentation\widgets\map\testmap_pages.dart'
with open(path, 'r', encoding='utf-8') as f:
content = f.read()
# Find the result.fold block
old_start = ' result.fold('
pos = content.find(old_start)
if pos < 0:
print('ERROR: result.fold not found')
sys.exit(1)
print(f'Found result.fold at char {pos}')
# Find the end of fold: " );" followed by " } catch"
# Search for the exact pattern
end_pattern = '\n );\n } catch'
end_pos = content.find(end_pattern, pos)
if end_pos < 0:
print(f'ERROR: fold end not found')
sys.exit(1)
end_pos += len('\n );')
print(f'Fold ends at char {end_pos}')
old_block = content[pos:end_pos]
print('Old block length:', len(old_block))
print('Old block preview:', repr(old_block[:80]))
new_block = ''' var needRequery = false;
result.fold(
(failure) {
final failMsg = failure.toString();
if (failMsg.contains('存在任务') || failMsg.contains('already exists')) {
needRequery = true;
return;
}
_showPageToast(message: "作业启动失败", type: ToastType.error);
taskCubit.clearCurrentTask();
setState(() {
isStartWork = false;
_workStatus = WorkStatus.idle;
});
return;
},
(taskId) {
taskCubit.updateCurrentTaskId(taskId);
},
);
if (needRequery) {
debugPrint('⚠️ [开始作业] 设备已有任务,重新查询任务池...');
await taskCubit.fetchAndFilterTask(deviceId);
await Future.delayed(const Duration(milliseconds: 300));
final existingTasks = taskCubit.state.activeTasks;
if (existingTasks.isNotEmpty) {
final existingTask = existingTasks.first;
taskCubit.selectTask(existingTask);
debugPrint('✅ [开始作业] 复用已有任务 #${existingTask.id},taskId已保存');
_showPageToast(message: "设备正在作业中", type: ToastType.success);
_saveDataToLocal();
return;
}
debugPrint('⚠️ [开始作业] 重新查询后仍未找到活跃任务');
_showPageToast(message: "设备正在作业中", type: ToastType.warn);
return;
}'''
new_content = content[:pos] + new_block + content[end_pos:]
with open(path, 'w', encoding='utf-8', newline='') as f:
f.write(new_content)
print('SUCCESS - File updated')