Merge branch 'dev' into test
This commit is contained in:
commit
86999f0b83
4 files changed
+29
-10
No files matched your search
@@ -195,11 +195,11 @@ WHERE c002001 = ?
|
||||
return str(value)
|
||||
|
||||
@classmethod
|
||||
def _format_quota(cls, value) -> str:
|
||||
def _format_quota(cls, value, unit: str = "天") -> str:
|
||||
formatted = cls._format_number(value)
|
||||
if formatted == "暂无数据":
|
||||
return formatted
|
||||
return f"{formatted}天"
|
||||
return f"{formatted}{unit}"
|
||||
|
||||
@staticmethod
|
||||
def _resolve_response_year(record: dict | None, requested_year: int | None) -> str:
|
||||
@@ -210,13 +210,13 @@ WHERE c002001 = ?
|
||||
return str(datetime.now().year)
|
||||
|
||||
@classmethod
|
||||
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None) -> str:
|
||||
def _render_table_row(cls, index: int, title: str, record: dict | None, requested_year: int | None, quota_unit: str = "天") -> str:
|
||||
response_year = cls._resolve_response_year(record, requested_year)
|
||||
if not record:
|
||||
return f"| {index} | {title} | {response_year} | 暂无数据 | 暂无数据 | 暂无数据 |"
|
||||
total = cls._format_quota(record.get('total_hours'))
|
||||
used = cls._format_quota(record.get('used_hours'))
|
||||
remaining = cls._format_quota(record.get('remaining_hours'))
|
||||
total = cls._format_quota(record.get('total_hours'), quota_unit)
|
||||
used = cls._format_quota(record.get('used_hours'), quota_unit)
|
||||
remaining = cls._format_quota(record.get('remaining_hours'), "小时")
|
||||
return f"| {index} | {title} | {response_year} | {total} | {used} | {remaining} |"
|
||||
|
||||
@classmethod
|
||||
@@ -249,7 +249,7 @@ WHERE c002001 = ?
|
||||
sections.append(cls._render_table_row(index, "年假", annual_record, requested_year))
|
||||
index += 1
|
||||
if leave_type in ("childcare", "all"):
|
||||
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year))
|
||||
sections.append(cls._render_table_row(index, "育儿假", childcare_record, requested_year, "小时"))
|
||||
index += 1
|
||||
|
||||
sections.extend(
|
||||
|
||||
@@ -35,3 +35,4 @@ lxml==6.0.2
|
||||
typer==0.17.4
|
||||
croniter
|
||||
pyyaml
|
||||
minio>=7.2.0
|
||||
+20
-2
@@ -4,12 +4,29 @@ backend/worker_kb.py
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
from app import create_app
|
||||
from app.services.knowledge_cleaning.queue_service import process_next_clean_job
|
||||
|
||||
_LOG_FORMAT = '%(asctime)s %(levelname)s [kb-worker] %(message)s'
|
||||
_LOG_DATEFMT = '%Y-%m-%d %H:%M:%S'
|
||||
|
||||
|
||||
def _configure_logging() -> logging.Logger:
|
||||
logger = logging.getLogger('kb-worker')
|
||||
if logger.handlers:
|
||||
return logger
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
handler.setFormatter(logging.Formatter(_LOG_FORMAT, datefmt=_LOG_DATEFMT))
|
||||
logger.addHandler(handler)
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.propagate = False
|
||||
return logger
|
||||
|
||||
|
||||
def _resolve_config_name() -> str:
|
||||
"""Keep the worker aligned with container/runtime environment selection."""
|
||||
@@ -30,17 +47,18 @@ def _resolve_config_name() -> str:
|
||||
|
||||
|
||||
def main():
|
||||
log = _configure_logging()
|
||||
app = create_app(_resolve_config_name())
|
||||
poll_seconds = float(app.config.get('KB_WORKER_POLL_SECONDS', 2))
|
||||
|
||||
with app.app_context():
|
||||
print(f'[kb-worker] started, poll_seconds={poll_seconds}')
|
||||
log.info('started, poll_seconds=%s', poll_seconds)
|
||||
while True:
|
||||
processed, message = process_next_clean_job()
|
||||
if not processed:
|
||||
time.sleep(poll_seconds)
|
||||
continue
|
||||
print(f'[kb-worker] processed job: {message}')
|
||||
log.info('processed job: %s', message)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
const messages = {
|
||||
'en': {
|
||||
|
||||
Reference in new issue
Block a user