-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
不养闲人任务合并+优化ui路径+自定义副表名称+仅回满提前上班 #693
Changes from 12 commits
bbf136a
f1e531e
6d5f51a
6c54cc8
e656bac
0d00758
399d8d2
efae979
0acb94f
86937e1
24a0ef1
354b7d3
f662348
0846d63
bf5cba4
1c7775f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,7 @@ | |
add_release_dorm, | ||
check_dorm_ordering, | ||
find_next_task, | ||
merge_release_dorm, | ||
scheduling, | ||
try_add_release_dorm, | ||
) | ||
|
@@ -463,7 +464,11 @@ def plan_metadata(self): | |
__time = dorm.time | ||
else: | ||
__time = datetime.max | ||
need_early = True | ||
for x in __rest_agent: | ||
# 如果小组内没有耗尽,则提前8分钟上班 | ||
if self.op_data.operators[x].exhaust_require: | ||
need_early = False | ||
# 如果同小组也是rest_in_full则取最大休息时间 否则忽略 | ||
if x in low_priority: | ||
logger.debug("检测到回满组已经安排") | ||
|
@@ -489,6 +494,9 @@ def plan_metadata(self): | |
if __time < datetime.now(): | ||
__time = datetime.now() | ||
if __time != datetime.max: | ||
if need_early: | ||
__time -= timedelta(minutes=8) | ||
logger.info("全组无耗尽,提前8分钟上班") | ||
self.tasks.append( | ||
SchedulerTask( | ||
time=__time, | ||
|
@@ -578,19 +586,33 @@ def plan_metadata(self): | |
logger.debug("检测到时间数据不存在") | ||
self.op_data.reset_dorm_time() | ||
self.error = True | ||
self.tasks.sort(key=lambda task: task.time) | ||
# 最后再做不养闲人刷新 | ||
if self.op_data.config.free_room: | ||
|
||
def should_keep(task): | ||
if task.type != TaskTypes.RELEASE_DORM: | ||
return True | ||
name = task.meta_data | ||
for key, value in task.plan.items(): | ||
dorm_name = key | ||
dorm_op = value | ||
break | ||
if ( | ||
self.op_data.operators[name].current_room != dorm_name | ||
or dorm_op[self.op_data.operators[name].current_index] != "Free" | ||
): | ||
logger.info(f"检测到{task.meta_data}不在对应位置,移除相关任务") | ||
return False | ||
i, d = self.op_data.get_dorm_by_name(task.meta_data) | ||
if i is None: | ||
logger.info(f"检测到{task.meta_data}不在宿舍,移除相关任务") | ||
return False | ||
return True | ||
|
||
self.tasks = [t for t in self.tasks if should_keep(t)] | ||
merge_interval = config.conf.merge_interval | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
merge_release_dorm(self.tasks, merge_interval) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这部分能移到任务开始的时候嘛。那里有个任务调度逻辑 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这样做问题就是生成不养闲人时候,假如不养闲人就是最近的任务怎么办 |
||
|
||
def infra_main(self): | ||
"""位于基建首页""" | ||
|
@@ -3287,6 +3309,7 @@ def append_maa_task(self, type): | |
"credit_fight": conf.maa_credit_fight | ||
and "" not in self.stages | ||
and self.credit_fight is None, | ||
"select_formation": conf.credit_fight.squad, | ||
"force_shopping_if_credit_full": conf.maa_mall_ignore_blacklist_when_full, | ||
}, | ||
) | ||
|
@@ -3339,6 +3362,9 @@ def maa_plan_solver(self, tasks="All", one_time=False): | |
): | ||
self.MAA.stop() | ||
hard_stop = True | ||
elif config.stop_maa.is_set(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这是里是什么意思呀 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 就是立即停止上面有个停止maa按钮,点了那个可以中断maa的任务。 |
||
self.MAA.stop() | ||
hard_stop = True | ||
else: | ||
self.sleep(5) | ||
if hard_stop: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,7 @@ class BackupPlan(BaseModel): | |
task: Task = {} | ||
trigger: Trigger = {} | ||
trigger_timing: str = "AFTER_PLANNING" | ||
name: str = "plan" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 名字可以不用传到后端,因为后端不需要名字对吧? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 是的,只在前端的标题里面看 |
||
|
||
|
||
class PlanModel(BaseModel): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,6 +141,7 @@ def __init__( | |
trigger: Optional[LogicExpression] = None, | ||
task: Optional[dict[str, list[str]]] = None, | ||
trigger_timing: Optional[str] = None, | ||
name: Optional[str] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我觉得标题在 plan.json存就好 了,没必要传到后端? |
||
): | ||
""" | ||
Args: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
mimetypes.add_type("text/css", ".css") | ||
mimetypes.add_type("application/javascript", ".js") | ||
|
||
app = Flask(__name__, static_folder="dist", static_url_path="") | ||
app = Flask(__name__, static_folder="ui/dist", static_url_path="") | ||
sock = Sock(app) | ||
CORS(app) | ||
|
||
|
@@ -63,17 +63,17 @@ def decorated_function(*args, **kwargs): | |
|
||
@app.route("/<path:path>") | ||
def serve_index(path): | ||
return send_from_directory("dist", path) | ||
return send_from_directory("ui/dist", path) | ||
|
||
|
||
@app.errorhandler(404) | ||
def not_found(e): | ||
if (path := request.path).startswith("/docs"): | ||
try: | ||
return send_from_directory("dist" + path, "index.html") | ||
return send_from_directory("ui/dist" + path, "index.html") | ||
except NotFound: | ||
return "<h1>404 Not Found</h1>", 404 | ||
return send_from_directory("dist", "index.html") | ||
return send_from_directory("ui/dist", "index.html") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ui 的 read me 可以更新一下嘛 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改好了 |
||
|
||
|
||
@app.route("/conf", methods=["GET", "POST"]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup> | ||
import { inject } from 'vue' | ||
const show = inject('show_name_editor') | ||
|
||
import { storeToRefs } from 'pinia' | ||
import { usePlanStore } from '@/stores/plan' | ||
|
||
const plan_store = usePlanStore() | ||
const { sub_plan, backup_plans } = storeToRefs(plan_store) | ||
|
||
const triggerTimingOptions = [ | ||
{ label: '任务开始', value: 'BEGINNING' }, | ||
{ label: '下班结束', value: 'BEFORE_PLANNING' }, | ||
{ label: '上班结束', value: 'AFTER_PLANNING' }, | ||
{ label: '任务结束', value: 'END' } | ||
] | ||
|
||
function update_trigger(data) { | ||
backup_plans.value[sub_plan.value].trigger = data | ||
} | ||
</script> | ||
|
||
<template> | ||
<n-modal | ||
v-model:show="show" | ||
preset="card" | ||
title="重命名" | ||
transform-origin="center" | ||
style="width: auto; max-width: 90vw" | ||
> | ||
<div class="dropdown-container"> | ||
<label class="dropdown-label">副表名称 </label> | ||
<n-input v-model:value="backup_plans[sub_plan].name"> </n-input> | ||
</div> | ||
</n-modal> | ||
</template> | ||
|
||
<style> | ||
.dropdown-container { | ||
display: flex; | ||
align-items: center; | ||
margin-top: 5px; | ||
} | ||
|
||
.dropdown-label { | ||
flex: 0 0 40%; | ||
max-width: 125px; | ||
} | ||
|
||
.dropdown-select { | ||
flex: 1; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行不需要了对吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前append的任务应该默认是在tasks的最后一个吧?我不是很清楚有没有排过序,就加了一行这个。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scheduling 方法每次任务开始的时候都自带排序的,所以不要刻意排序