feat: 工参每周一一份并提前缓存,登录后自动补缺;评估按周一取工参,指标等平台同步三天后再查
- 工参从 2024-01-01 起每周一一份,排队任务一次补一份,新的周先补;一个地市同时只取一份 - 大数据平台账号登录成功后排补取,排队进程每 10 分钟检查缺的周;排队进程重启时放开没取完的快照 - 拆除前工参用拆除日上一周的周一,拆除后用当周的周一;待拆小区不参与周边站和指标匹配 - 一周的指标等周日过后第 3 天才查,没到时间在结果说明里写明哪天之后有数据 - AI 工作区没就绪时开通接口返回 200,改为等待重试,最多 150 秒 - 排任务加锁,避免多个线程同时排时用到已关闭的连接池 - 运行面板显示各地市工参缓存进度
This commit is contained in:
@@ -12,6 +12,7 @@ from sqlalchemy import delete, select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.api.deps import Actor, current_actor
|
||||
from app.collect.gongcan import short_city
|
||||
from app.db import get_session
|
||||
from app.evaluate.compute import NEIGHBOR_SITES
|
||||
from app.evaluate.demand import (
|
||||
@@ -49,27 +50,19 @@ def _user(actor: Actor) -> Actor:
|
||||
return actor
|
||||
|
||||
|
||||
def _short_city(name: str) -> str:
|
||||
text = (name or "").strip()
|
||||
for suffix in ("分公司", "市"):
|
||||
if text.endswith(suffix) and len(text) > len(suffix):
|
||||
text = text[: -len(suffix)]
|
||||
return text
|
||||
|
||||
|
||||
def _default_city(session: Session, actor: Actor) -> str:
|
||||
if actor.kind == "nqi":
|
||||
account = session.scalar(select(NqiAccount).where(NqiAccount.login_id == actor.id))
|
||||
if account is not None and account.city_name:
|
||||
return _short_city(account.city_name)
|
||||
return short_city(account.city_name)
|
||||
pooled = session.scalar(select(NqiAccount.city_name).where(NqiAccount.city_name != "").order_by(NqiAccount.saved_at.desc()))
|
||||
if pooled:
|
||||
return _short_city(pooled)
|
||||
return short_city(pooled)
|
||||
return session.scalar(select(GongcanSnapshot.city).order_by(GongcanSnapshot.id.desc())) or ""
|
||||
|
||||
|
||||
def _check_city(value: object) -> str:
|
||||
city = _short_city(str(value or ""))
|
||||
city = short_city(value)
|
||||
if not city:
|
||||
raise _bad("请填写地市")
|
||||
if len(city) > 32:
|
||||
|
||||
Reference in New Issue
Block a user