Commit ·
7660d20
1
Parent(s): d525ec8
未使用の「固定シフトパターン」「固定不可日」機能を削除
Browse filesDB・モデル・リポジトリ・Web/デスクトップUI・ソルバー・ヘルプから関連コードを
全て除去。既存DBの fixed_patterns / fixed_unavailable_dates テーブルは
initialize_db() 実行時に DROP TABLE で自動クリーンアップする。
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- README.md +2 -2
- db/database.py +7 -16
- db/repositories.py +3 -62
- db/seed_data.json +0 -2
- db/seeder.py +0 -2
- models/employee.py +1 -19
- optimizer/solver.py +17 -22
- routes/employees.py +2 -13
- routes/settings_routes.py +2 -2
- routes/shifts.py +0 -15
- scripts/migrate_to_supabase.py +0 -4
- scripts/seed_test_data.py +1 -3
- templates/employees/form.html +0 -78
- templates/help/index.html +0 -7
- ui/employee_view.py +4 -108
- ui/help_view.py +0 -2
- ui/schedule_view.py +3 -3
- ui/shift_input_view.py +8 -31
README.md
CHANGED
|
@@ -19,7 +19,7 @@ pinned: false
|
|
| 19 |
|
| 20 |
| 機能 | 内容 |
|
| 21 |
|---|---|
|
| 22 |
-
| 従業員管理 | 氏名・雇用形態・所属ポジション・勤務時間帯・ポジション別習熟度
|
| 23 |
| 希望シフト入力 | 2週間単位でシフトパターン(14種類)またはカスタム時刻を入力。←/→キーで従業員切替、数字キーでパターン選択 |
|
| 24 |
| シフト自動生成 | CP-SATソルバーによる最適化(正社員優先・リーダー要件・ポジション制約を考慮) |
|
| 25 |
| シフト編集 | 朝食/ディナー別タブのカレンダー形式で確認・手動修正。他時間帯専任メンバーのワンタッチ表示切替 |
|
|
@@ -35,7 +35,7 @@ pinned: false
|
|
| 35 |
|
| 36 |
| 属性 | 選択肢 | 説明 |
|
| 37 |
|---|---|---|
|
| 38 |
-
| 雇用形態 | 正社員 / アルバイト | アルバイトは
|
| 39 |
| 所属ポジション | どちらでも / ホール専任 / キッチン専任 | 専任設定はシフト自動生成の硬制約 |
|
| 40 |
| 勤務時間帯 | どちらでも / 朝食専任 / ディナー専任 | シフト表示タブのデフォルトフィルタに使用 |
|
| 41 |
| ホール習熟度 | リーダー / ベテラン / 一般 / 新人 | ホールのリーダー要件に反映 |
|
|
|
|
| 19 |
|
| 20 |
| 機能 | 内容 |
|
| 21 |
|---|---|
|
| 22 |
+
| 従業員管理 | 氏名・雇用形態・所属ポジション・勤務時間帯・ポジション別習熟度を登録 |
|
| 23 |
| 希望シフト入力 | 2週間単位でシフトパターン(14種類)またはカスタム時刻を入力。←/→キーで従業員切替、数字キーでパターン選択 |
|
| 24 |
| シフト自動生成 | CP-SATソルバーによる最適化(正社員優先・リーダー要件・ポジション制約を考慮) |
|
| 25 |
| シフト編集 | 朝食/ディナー別タブのカレンダー形式で確認・手動修正。他時間帯専任メンバーのワンタッチ表示切替 |
|
|
|
|
| 35 |
|
| 36 |
| 属性 | 選択肢 | 説明 |
|
| 37 |
|---|---|---|
|
| 38 |
+
| 雇用形態 | 正社員 / アルバイト | アルバイトは2週間単位で希望シフトを入力 |
|
| 39 |
| 所属ポジション | どちらでも / ホール専任 / キッチン専任 | 専任設定はシフト自動生成の硬制約 |
|
| 40 |
| 勤務時間帯 | どちらでも / 朝食専任 / ディナー専任 | シフト表示タブのデフォルトフィルタに使用 |
|
| 41 |
| ホール習熟度 | リーダー / ベテラン / 一般 / 新人 | ホールのリーダー要件に反映 |
|
db/database.py
CHANGED
|
@@ -257,20 +257,6 @@ _CREATE_TABLES = [
|
|
| 257 |
CHECK(kitchen_skill_dinner IN ('leader','veteran','general','beginner')),
|
| 258 |
is_active INTEGER NOT NULL DEFAULT 1
|
| 259 |
)""",
|
| 260 |
-
"""CREATE TABLE IF NOT EXISTS fixed_patterns (
|
| 261 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 262 |
-
employee_id INTEGER NOT NULL REFERENCES employees(id) ON DELETE CASCADE,
|
| 263 |
-
day_of_week INTEGER NOT NULL CHECK(day_of_week BETWEEN 0 AND 6),
|
| 264 |
-
breakfast INTEGER NOT NULL DEFAULT 0,
|
| 265 |
-
dinner INTEGER NOT NULL DEFAULT 0,
|
| 266 |
-
UNIQUE(employee_id, day_of_week)
|
| 267 |
-
)""",
|
| 268 |
-
"""CREATE TABLE IF NOT EXISTS fixed_unavailable_dates (
|
| 269 |
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 270 |
-
employee_id INTEGER NOT NULL REFERENCES employees(id) ON DELETE CASCADE,
|
| 271 |
-
date TEXT NOT NULL,
|
| 272 |
-
UNIQUE(employee_id, date)
|
| 273 |
-
)""",
|
| 274 |
"""CREATE TABLE IF NOT EXISTS schedule_periods (
|
| 275 |
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 276 |
start_date TEXT NOT NULL,
|
|
@@ -409,8 +395,6 @@ _MIGRATIONS = [
|
|
| 409 |
_INDEXES = [
|
| 410 |
"CREATE INDEX IF NOT EXISTS idx_shift_assignments_period ON shift_assignments(period_id)",
|
| 411 |
"CREATE INDEX IF NOT EXISTS idx_shift_requests_period ON shift_requests(period_id)",
|
| 412 |
-
"CREATE INDEX IF NOT EXISTS idx_fixed_patterns_emp ON fixed_patterns(employee_id)",
|
| 413 |
-
"CREATE INDEX IF NOT EXISTS idx_fixed_unavail_emp ON fixed_unavailable_dates(employee_id)",
|
| 414 |
"CREATE INDEX IF NOT EXISTS idx_reservation_period ON reservation_counts(period_id)",
|
| 415 |
"CREATE INDEX IF NOT EXISTS idx_schedule_notes_period ON schedule_notes(period_id)",
|
| 416 |
"CREATE INDEX IF NOT EXISTS idx_staff_notes_period ON staff_notes(period_id)",
|
|
@@ -432,6 +416,13 @@ def initialize_db():
|
|
| 432 |
for idx in _INDEXES:
|
| 433 |
conn.execute(idx)
|
| 434 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 435 |
added_cols = set()
|
| 436 |
for table, col, definition in _MIGRATIONS:
|
| 437 |
try:
|
|
|
|
| 257 |
CHECK(kitchen_skill_dinner IN ('leader','veteran','general','beginner')),
|
| 258 |
is_active INTEGER NOT NULL DEFAULT 1
|
| 259 |
)""",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
"""CREATE TABLE IF NOT EXISTS schedule_periods (
|
| 261 |
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 262 |
start_date TEXT NOT NULL,
|
|
|
|
| 395 |
_INDEXES = [
|
| 396 |
"CREATE INDEX IF NOT EXISTS idx_shift_assignments_period ON shift_assignments(period_id)",
|
| 397 |
"CREATE INDEX IF NOT EXISTS idx_shift_requests_period ON shift_requests(period_id)",
|
|
|
|
|
|
|
| 398 |
"CREATE INDEX IF NOT EXISTS idx_reservation_period ON reservation_counts(period_id)",
|
| 399 |
"CREATE INDEX IF NOT EXISTS idx_schedule_notes_period ON schedule_notes(period_id)",
|
| 400 |
"CREATE INDEX IF NOT EXISTS idx_staff_notes_period ON staff_notes(period_id)",
|
|
|
|
| 416 |
for idx in _INDEXES:
|
| 417 |
conn.execute(idx)
|
| 418 |
|
| 419 |
+
# 廃止された固定シフトパターン/固定不可日テーブルを既存DBから削除
|
| 420 |
+
for table in ("fixed_patterns", "fixed_unavailable_dates"):
|
| 421 |
+
try:
|
| 422 |
+
conn.execute(f"DROP TABLE IF EXISTS {table}")
|
| 423 |
+
except Exception:
|
| 424 |
+
pass
|
| 425 |
+
|
| 426 |
added_cols = set()
|
| 427 |
for table, col, definition in _MIGRATIONS:
|
| 428 |
try:
|
db/repositories.py
CHANGED
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
| 3 |
from typing import Optional
|
| 4 |
from datetime import date as _date
|
| 5 |
from db.database import get_connection, Connection
|
| 6 |
-
from models.employee import Employee
|
| 7 |
from models.schedule import ShiftRequest, ShiftAssignment, SchedulePeriod
|
| 8 |
from utils.constants import EmploymentType, SkillLevel, TimeSlot, Position, PrimaryPosition
|
| 9 |
from cache import cache
|
|
@@ -21,28 +21,7 @@ def get_all_employees(active_only: bool = True) -> list[Employee]:
|
|
| 21 |
conn.close()
|
| 22 |
return []
|
| 23 |
|
| 24 |
-
|
| 25 |
-
ph = ",".join(["?" ] * len(emp_ids))
|
| 26 |
-
|
| 27 |
-
# fixed_patterns を一括取得(N+1解消)
|
| 28 |
-
pat_rows = conn.execute(
|
| 29 |
-
f"SELECT * FROM fixed_patterns WHERE employee_id IN ({ph}) ORDER BY employee_id, day_of_week",
|
| 30 |
-
emp_ids
|
| 31 |
-
).fetchall()
|
| 32 |
-
pat_map: dict[int, list] = {}
|
| 33 |
-
for p in pat_rows:
|
| 34 |
-
pat_map.setdefault(p["employee_id"], []).append(p)
|
| 35 |
-
|
| 36 |
-
# fixed_unavailable_dates を一括取得(N+1解消)
|
| 37 |
-
unavail_rows = conn.execute(
|
| 38 |
-
f"SELECT employee_id, date FROM fixed_unavailable_dates WHERE employee_id IN ({ph}) ORDER BY employee_id, date",
|
| 39 |
-
emp_ids
|
| 40 |
-
).fetchall()
|
| 41 |
-
unavail_map: dict[int, list] = {}
|
| 42 |
-
for u in unavail_rows:
|
| 43 |
-
unavail_map.setdefault(u["employee_id"], []).append(u["date"])
|
| 44 |
-
|
| 45 |
-
employees = [_row_to_employee_preloaded(row, pat_map, unavail_map) for row in rows]
|
| 46 |
conn.close()
|
| 47 |
return employees
|
| 48 |
|
|
@@ -93,8 +72,6 @@ def save_employee(emp: Employee) -> Employee:
|
|
| 93 |
"UPDATE employees SET name=?, employment_type=?, hall_skill_breakfast=?, hall_skill_dinner=?, kitchen_skill_breakfast=?, kitchen_skill_dinner=?, primary_position=?, output_position=?, primary_timeslot=?, can_work_both_positions=?, can_open=?, can_cleanup=?, always_available_breakfast=?, always_available_dinner=?, hourly_wage=?, has_social_insurance=?, is_active=? WHERE id=?",
|
| 94 |
(emp.name, emp.employment_type.value, emp.hall_skill_breakfast.value, emp.hall_skill_dinner.value, emp.kitchen_skill_breakfast.value, emp.kitchen_skill_dinner.value, pp, op, pt, both, opn, cln, avail_b, avail_d, emp.hourly_wage, si, int(emp.is_active), emp.id)
|
| 95 |
)
|
| 96 |
-
_save_fixed_patterns(conn, emp)
|
| 97 |
-
_save_fixed_unavailable_dates(conn, emp)
|
| 98 |
conn.commit()
|
| 99 |
conn.close()
|
| 100 |
cache.delete_memoized(get_all_employees)
|
|
@@ -202,7 +179,7 @@ def reorder_employees(ordered_ids: list[int]):
|
|
| 202 |
cache.delete_memoized(get_all_employees)
|
| 203 |
|
| 204 |
|
| 205 |
-
def _row_to_employee_preloaded(row
|
| 206 |
eid = row["id"]
|
| 207 |
keys = row.keys()
|
| 208 |
pp_val = row["primary_position"] if "primary_position" in keys and row["primary_position"] else None
|
|
@@ -226,23 +203,10 @@ def _row_to_employee_preloaded(row, pat_map: dict, unavail_map: dict) -> Employe
|
|
| 226 |
hourly_wage=int(row["hourly_wage"]) if "hourly_wage" in keys and row["hourly_wage"] else 0,
|
| 227 |
has_social_insurance=bool(row["has_social_insurance"]) if "has_social_insurance" in keys else False,
|
| 228 |
is_active=bool(row["is_active"]),
|
| 229 |
-
fixed_patterns=[
|
| 230 |
-
FixedPattern(p["day_of_week"], bool(p["breakfast"]), bool(p["dinner"]))
|
| 231 |
-
for p in pat_map.get(eid, [])
|
| 232 |
-
],
|
| 233 |
-
fixed_unavailable_dates=unavail_map.get(eid, []),
|
| 234 |
)
|
| 235 |
|
| 236 |
|
| 237 |
def _row_to_employee(row, conn) -> Employee:
|
| 238 |
-
patterns = conn.execute(
|
| 239 |
-
"SELECT * FROM fixed_patterns WHERE employee_id=? ORDER BY day_of_week",
|
| 240 |
-
(row["id"],)
|
| 241 |
-
).fetchall()
|
| 242 |
-
unavail = conn.execute(
|
| 243 |
-
"SELECT date FROM fixed_unavailable_dates WHERE employee_id=? ORDER BY date",
|
| 244 |
-
(row["id"],)
|
| 245 |
-
).fetchall()
|
| 246 |
keys = row.keys()
|
| 247 |
pp_val = row["primary_position"] if "primary_position" in keys and row["primary_position"] else None
|
| 248 |
op_val = row["output_position"] if "output_position" in keys and row["output_position"] else None
|
|
@@ -273,32 +237,9 @@ def _row_to_employee(row, conn) -> Employee:
|
|
| 273 |
has_social_insurance=si_val,
|
| 274 |
primary_timeslot=TimeSlot(pt_val) if pt_val else None,
|
| 275 |
is_active=bool(row["is_active"]),
|
| 276 |
-
fixed_patterns=[
|
| 277 |
-
FixedPattern(p["day_of_week"], bool(p["breakfast"]), bool(p["dinner"]))
|
| 278 |
-
for p in patterns
|
| 279 |
-
],
|
| 280 |
-
fixed_unavailable_dates=[u["date"] for u in unavail],
|
| 281 |
)
|
| 282 |
|
| 283 |
|
| 284 |
-
def _save_fixed_patterns(conn, emp: Employee):
|
| 285 |
-
conn.execute("DELETE FROM fixed_patterns WHERE employee_id=?", (emp.id,))
|
| 286 |
-
for p in emp.fixed_patterns:
|
| 287 |
-
conn.execute(
|
| 288 |
-
"INSERT INTO fixed_patterns (employee_id, day_of_week, breakfast, dinner) VALUES (?,?,?,?)",
|
| 289 |
-
(emp.id, p.day_of_week, int(p.breakfast), int(p.dinner))
|
| 290 |
-
)
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
def _save_fixed_unavailable_dates(conn, emp: Employee):
|
| 294 |
-
conn.execute("DELETE FROM fixed_unavailable_dates WHERE employee_id=?", (emp.id,))
|
| 295 |
-
for d in emp.fixed_unavailable_dates:
|
| 296 |
-
conn.execute(
|
| 297 |
-
"INSERT INTO fixed_unavailable_dates (employee_id, date) VALUES (?,?)",
|
| 298 |
-
(emp.id, d)
|
| 299 |
-
)
|
| 300 |
-
|
| 301 |
-
|
| 302 |
# ── シフト期間 ──────────────────────────────────────────────────────────
|
| 303 |
|
| 304 |
def try_start_generation(period_id: int) -> bool:
|
|
|
|
| 3 |
from typing import Optional
|
| 4 |
from datetime import date as _date
|
| 5 |
from db.database import get_connection, Connection
|
| 6 |
+
from models.employee import Employee
|
| 7 |
from models.schedule import ShiftRequest, ShiftAssignment, SchedulePeriod
|
| 8 |
from utils.constants import EmploymentType, SkillLevel, TimeSlot, Position, PrimaryPosition
|
| 9 |
from cache import cache
|
|
|
|
| 21 |
conn.close()
|
| 22 |
return []
|
| 23 |
|
| 24 |
+
employees = [_row_to_employee_preloaded(row) for row in rows]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
conn.close()
|
| 26 |
return employees
|
| 27 |
|
|
|
|
| 72 |
"UPDATE employees SET name=?, employment_type=?, hall_skill_breakfast=?, hall_skill_dinner=?, kitchen_skill_breakfast=?, kitchen_skill_dinner=?, primary_position=?, output_position=?, primary_timeslot=?, can_work_both_positions=?, can_open=?, can_cleanup=?, always_available_breakfast=?, always_available_dinner=?, hourly_wage=?, has_social_insurance=?, is_active=? WHERE id=?",
|
| 73 |
(emp.name, emp.employment_type.value, emp.hall_skill_breakfast.value, emp.hall_skill_dinner.value, emp.kitchen_skill_breakfast.value, emp.kitchen_skill_dinner.value, pp, op, pt, both, opn, cln, avail_b, avail_d, emp.hourly_wage, si, int(emp.is_active), emp.id)
|
| 74 |
)
|
|
|
|
|
|
|
| 75 |
conn.commit()
|
| 76 |
conn.close()
|
| 77 |
cache.delete_memoized(get_all_employees)
|
|
|
|
| 179 |
cache.delete_memoized(get_all_employees)
|
| 180 |
|
| 181 |
|
| 182 |
+
def _row_to_employee_preloaded(row) -> Employee:
|
| 183 |
eid = row["id"]
|
| 184 |
keys = row.keys()
|
| 185 |
pp_val = row["primary_position"] if "primary_position" in keys and row["primary_position"] else None
|
|
|
|
| 203 |
hourly_wage=int(row["hourly_wage"]) if "hourly_wage" in keys and row["hourly_wage"] else 0,
|
| 204 |
has_social_insurance=bool(row["has_social_insurance"]) if "has_social_insurance" in keys else False,
|
| 205 |
is_active=bool(row["is_active"]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
)
|
| 207 |
|
| 208 |
|
| 209 |
def _row_to_employee(row, conn) -> Employee:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 210 |
keys = row.keys()
|
| 211 |
pp_val = row["primary_position"] if "primary_position" in keys and row["primary_position"] else None
|
| 212 |
op_val = row["output_position"] if "output_position" in keys and row["output_position"] else None
|
|
|
|
| 237 |
has_social_insurance=si_val,
|
| 238 |
primary_timeslot=TimeSlot(pt_val) if pt_val else None,
|
| 239 |
is_active=bool(row["is_active"]),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
)
|
| 241 |
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
# ── シフト期間 ──────────────────────────────────────────────────────────
|
| 244 |
|
| 245 |
def try_start_generation(period_id: int) -> bool:
|
db/seed_data.json
CHANGED
|
@@ -381,8 +381,6 @@
|
|
| 381 |
"primary_timeslot": null
|
| 382 |
}
|
| 383 |
],
|
| 384 |
-
"fixed_patterns": [],
|
| 385 |
-
"fixed_unavailable_dates": [],
|
| 386 |
"schedule_periods": [
|
| 387 |
{
|
| 388 |
"id": 1,
|
|
|
|
| 381 |
"primary_timeslot": null
|
| 382 |
}
|
| 383 |
],
|
|
|
|
|
|
|
| 384 |
"schedule_periods": [
|
| 385 |
{
|
| 386 |
"id": 1,
|
db/seeder.py
CHANGED
|
@@ -7,8 +7,6 @@ _SEED_FILE = Path(__file__).parent / "seed_data.json"
|
|
| 7 |
|
| 8 |
_TABLE_ORDER = [
|
| 9 |
"employees",
|
| 10 |
-
"fixed_patterns",
|
| 11 |
-
"fixed_unavailable_dates",
|
| 12 |
"schedule_periods",
|
| 13 |
"shift_requests",
|
| 14 |
"shift_assignments",
|
|
|
|
| 7 |
|
| 8 |
_TABLE_ORDER = [
|
| 9 |
"employees",
|
|
|
|
|
|
|
| 10 |
"schedule_periods",
|
| 11 |
"shift_requests",
|
| 12 |
"shift_assignments",
|
models/employee.py
CHANGED
|
@@ -1,15 +1,8 @@
|
|
| 1 |
-
from dataclasses import dataclass
|
| 2 |
from typing import Optional
|
| 3 |
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 4 |
|
| 5 |
|
| 6 |
-
@dataclass
|
| 7 |
-
class FixedPattern:
|
| 8 |
-
day_of_week: int # 0=月, 6=日
|
| 9 |
-
breakfast: bool = False
|
| 10 |
-
dinner: bool = False
|
| 11 |
-
|
| 12 |
-
|
| 13 |
@dataclass
|
| 14 |
class Employee:
|
| 15 |
id: Optional[int]
|
|
@@ -29,8 +22,6 @@ class Employee:
|
|
| 29 |
primary_timeslot: Optional[TimeSlot] = None # None = どちらでも可
|
| 30 |
hourly_wage: int = 0
|
| 31 |
has_social_insurance: bool = False
|
| 32 |
-
fixed_patterns: list[FixedPattern] = field(default_factory=list)
|
| 33 |
-
fixed_unavailable_dates: list[str] = field(default_factory=list) # YYYY-MM-DD
|
| 34 |
is_active: bool = True
|
| 35 |
|
| 36 |
def skill_for(self, position: str, time_slot: TimeSlot) -> SkillLevel:
|
|
@@ -49,15 +40,6 @@ class Employee:
|
|
| 49 |
"""リーダーかどうか"""
|
| 50 |
return self.skill_for(position, time_slot) == SkillLevel.LEADER
|
| 51 |
|
| 52 |
-
def has_fixed_pattern(self) -> bool:
|
| 53 |
-
return any(p.breakfast or p.dinner for p in self.fixed_patterns)
|
| 54 |
-
|
| 55 |
-
def get_pattern(self, day_of_week: int) -> Optional[FixedPattern]:
|
| 56 |
-
for p in self.fixed_patterns:
|
| 57 |
-
if p.day_of_week == day_of_week:
|
| 58 |
-
return p
|
| 59 |
-
return None
|
| 60 |
-
|
| 61 |
def staff_category_rank(self) -> int:
|
| 62 |
"""シフト表での表示順カテゴリ: 0=社員, 1=専任スタッフ, 2=ホール・キッチン兼任スタッフ"""
|
| 63 |
if self.employment_type == EmploymentType.FULL_TIME:
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
from typing import Optional
|
| 3 |
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 4 |
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
@dataclass
|
| 7 |
class Employee:
|
| 8 |
id: Optional[int]
|
|
|
|
| 22 |
primary_timeslot: Optional[TimeSlot] = None # None = どちらでも可
|
| 23 |
hourly_wage: int = 0
|
| 24 |
has_social_insurance: bool = False
|
|
|
|
|
|
|
| 25 |
is_active: bool = True
|
| 26 |
|
| 27 |
def skill_for(self, position: str, time_slot: TimeSlot) -> SkillLevel:
|
|
|
|
| 40 |
"""リーダーかどうか"""
|
| 41 |
return self.skill_for(position, time_slot) == SkillLevel.LEADER
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def staff_category_rank(self) -> int:
|
| 44 |
"""シフト表での表示順カテゴリ: 0=社員, 1=専任スタッフ, 2=ホール・キッチン兼任スタッフ"""
|
| 45 |
if self.employment_type == EmploymentType.FULL_TIME:
|
optimizer/solver.py
CHANGED
|
@@ -363,11 +363,11 @@ def solve(
|
|
| 363 |
for e in active_employees:
|
| 364 |
# FIX①: FT社員を正しくカウント(実際の可用性チェックと統一)
|
| 365 |
if e.employment_type == EmploymentType.FULL_TIME:
|
| 366 |
-
ok = not off_map.get((e.id, ds), False)
|
| 367 |
elif slot == TimeSlot.BREAKFAST and e.always_available_breakfast:
|
| 368 |
-
ok =
|
| 369 |
elif slot == TimeSlot.DINNER and e.always_available_dinner:
|
| 370 |
-
ok =
|
| 371 |
else:
|
| 372 |
ok = req_map.get((e.id, ds, slot.value), False)
|
| 373 |
if not ok:
|
|
@@ -441,7 +441,7 @@ def solve(
|
|
| 441 |
model.add(assign[emp.id][ds][slot.value][pos.value] == 0)
|
| 442 |
|
| 443 |
# 1. 従業員は希望していない時間帯には入れない
|
| 444 |
-
# 常時出勤可スタッフは
|
| 445 |
for emp in active_employees:
|
| 446 |
for ds in date_strs:
|
| 447 |
for slot in slots:
|
|
@@ -449,12 +449,11 @@ def solve(
|
|
| 449 |
# 社員:休希望・有休の日以外は常時出勤可
|
| 450 |
# (朝のみ可/晩のみ可の日は該当しない時間帯への配置を禁止)
|
| 451 |
can_work = not off_map.get((emp.id, ds), False) \
|
| 452 |
-
and ds not in emp.fixed_unavailable_dates \
|
| 453 |
and slot_block_map.get((emp.id, ds)) != slot
|
| 454 |
elif slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 455 |
-
can_work =
|
| 456 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 457 |
-
can_work =
|
| 458 |
else:
|
| 459 |
can_work = req_map.get((emp.id, ds, slot.value), False)
|
| 460 |
for pos in positions:
|
|
@@ -539,8 +538,7 @@ def solve(
|
|
| 539 |
req_map.get((emp.id, ds, TimeSlot.BREAKFAST.value))
|
| 540 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 541 |
and not off_map.get((emp.id, ds), False)
|
| 542 |
-
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST
|
| 543 |
-
and ds not in emp.fixed_unavailable_dates)
|
| 544 |
)
|
| 545 |
]
|
| 546 |
open_vars = [assign[emp.id][ds][TimeSlot.BREAKFAST.value][pos.value] for emp in can_open_req]
|
|
@@ -584,8 +582,7 @@ def solve(
|
|
| 584 |
or emp.always_available_breakfast
|
| 585 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 586 |
and not off_map.get((emp.id, ds), False)
|
| 587 |
-
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST
|
| 588 |
-
and ds not in emp.fixed_unavailable_dates)
|
| 589 |
]
|
| 590 |
if min_cln > 0 and cln_vars:
|
| 591 |
model.add(sum(cln_vars) >= min(min_cln, len(cln_vars)))
|
|
@@ -598,8 +595,7 @@ def solve(
|
|
| 598 |
or emp.always_available_breakfast
|
| 599 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 600 |
and not off_map.get((emp.id, ds), False)
|
| 601 |
-
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST
|
| 602 |
-
and ds not in emp.fixed_unavailable_dates)
|
| 603 |
]
|
| 604 |
if ldr_cln_vars:
|
| 605 |
model.add(sum(ldr_cln_vars) >= min(min_cln_ldr, len(ldr_cln_vars)))
|
|
@@ -828,9 +824,9 @@ def solve(
|
|
| 828 |
if emp.primary_position.value != pos.value:
|
| 829 |
continue
|
| 830 |
if slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 831 |
-
slot_ok =
|
| 832 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 833 |
-
slot_ok =
|
| 834 |
else:
|
| 835 |
slot_ok = req_map.get((emp.id, ds, slot.value), False)
|
| 836 |
if slot_ok:
|
|
@@ -843,7 +839,7 @@ def solve(
|
|
| 843 |
for emp in active_employees:
|
| 844 |
if emp.employment_type != EmploymentType.FULL_TIME:
|
| 845 |
continue
|
| 846 |
-
if off_map.get((emp.id, ds), False)
|
| 847 |
continue
|
| 848 |
if slot_block_map.get((emp.id, ds)) == slot:
|
| 849 |
continue
|
|
@@ -1103,7 +1099,7 @@ def _log_employee_analysis(assignments, active_employees, date_strs, slots, posi
|
|
| 1103 |
logger.info(f" → 加入者平均{avg_si:.1f}回 / 未加入者平均{avg_non:.1f}回")
|
| 1104 |
if si_req_8h == 0 and si_emps_count > 0:
|
| 1105 |
logger.warning(" ⚠️ 社保加入PT全員が8h希望を提出していません。"
|
| 1106 |
-
"8時間のシフトパターンを提出するか、おまかせ
|
| 1107 |
|
| 1108 |
|
| 1109 |
def _log_assignment_summary(assignments, date_strs):
|
|
@@ -1207,12 +1203,11 @@ def _solve_best_effort(
|
|
| 1207 |
for slot in slots:
|
| 1208 |
if emp.employment_type == EmploymentType.FULL_TIME:
|
| 1209 |
can_work = not off_map.get((emp.id, ds), False) \
|
| 1210 |
-
and ds not in emp.fixed_unavailable_dates \
|
| 1211 |
and slot_block_map.get((emp.id, ds)) != slot
|
| 1212 |
elif slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 1213 |
-
can_work =
|
| 1214 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 1215 |
-
can_work =
|
| 1216 |
else:
|
| 1217 |
can_work = req_map.get((emp.id, ds, slot.value), False)
|
| 1218 |
for pos in positions:
|
|
@@ -1506,8 +1501,8 @@ def _diagnose_infeasible(
|
|
| 1506 |
or e.primary_position.value == pos.value):
|
| 1507 |
continue
|
| 1508 |
if e.employment_type == EmploymentType.FULL_TIME:
|
| 1509 |
-
# 正社員: off_map
|
| 1510 |
-
if off_map.get((e.id, ds), False)
|
| 1511 |
continue
|
| 1512 |
available.append(e)
|
| 1513 |
else:
|
|
|
|
| 363 |
for e in active_employees:
|
| 364 |
# FIX①: FT社員を正しくカウント(実際の可用性チェックと統一)
|
| 365 |
if e.employment_type == EmploymentType.FULL_TIME:
|
| 366 |
+
ok = not off_map.get((e.id, ds), False)
|
| 367 |
elif slot == TimeSlot.BREAKFAST and e.always_available_breakfast:
|
| 368 |
+
ok = True
|
| 369 |
elif slot == TimeSlot.DINNER and e.always_available_dinner:
|
| 370 |
+
ok = True
|
| 371 |
else:
|
| 372 |
ok = req_map.get((e.id, ds, slot.value), False)
|
| 373 |
if not ok:
|
|
|
|
| 441 |
model.add(assign[emp.id][ds][slot.value][pos.value] == 0)
|
| 442 |
|
| 443 |
# 1. 従業員は希望していない時間帯には入れない
|
| 444 |
+
# 常時出勤可スタッフはすべて勤務可能とする
|
| 445 |
for emp in active_employees:
|
| 446 |
for ds in date_strs:
|
| 447 |
for slot in slots:
|
|
|
|
| 449 |
# 社員:休希望・有休の日以外は常時出勤可
|
| 450 |
# (朝のみ可/晩のみ可の日は該当しない時間帯への配置を禁止)
|
| 451 |
can_work = not off_map.get((emp.id, ds), False) \
|
|
|
|
| 452 |
and slot_block_map.get((emp.id, ds)) != slot
|
| 453 |
elif slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 454 |
+
can_work = True
|
| 455 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 456 |
+
can_work = True
|
| 457 |
else:
|
| 458 |
can_work = req_map.get((emp.id, ds, slot.value), False)
|
| 459 |
for pos in positions:
|
|
|
|
| 538 |
req_map.get((emp.id, ds, TimeSlot.BREAKFAST.value))
|
| 539 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 540 |
and not off_map.get((emp.id, ds), False)
|
| 541 |
+
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST)
|
|
|
|
| 542 |
)
|
| 543 |
]
|
| 544 |
open_vars = [assign[emp.id][ds][TimeSlot.BREAKFAST.value][pos.value] for emp in can_open_req]
|
|
|
|
| 582 |
or emp.always_available_breakfast
|
| 583 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 584 |
and not off_map.get((emp.id, ds), False)
|
| 585 |
+
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST)
|
|
|
|
| 586 |
]
|
| 587 |
if min_cln > 0 and cln_vars:
|
| 588 |
model.add(sum(cln_vars) >= min(min_cln, len(cln_vars)))
|
|
|
|
| 595 |
or emp.always_available_breakfast
|
| 596 |
or (emp.employment_type == EmploymentType.FULL_TIME
|
| 597 |
and not off_map.get((emp.id, ds), False)
|
| 598 |
+
and slot_block_map.get((emp.id, ds)) != TimeSlot.BREAKFAST)
|
|
|
|
| 599 |
]
|
| 600 |
if ldr_cln_vars:
|
| 601 |
model.add(sum(ldr_cln_vars) >= min(min_cln_ldr, len(ldr_cln_vars)))
|
|
|
|
| 824 |
if emp.primary_position.value != pos.value:
|
| 825 |
continue
|
| 826 |
if slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 827 |
+
slot_ok = True
|
| 828 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 829 |
+
slot_ok = True
|
| 830 |
else:
|
| 831 |
slot_ok = req_map.get((emp.id, ds, slot.value), False)
|
| 832 |
if slot_ok:
|
|
|
|
| 839 |
for emp in active_employees:
|
| 840 |
if emp.employment_type != EmploymentType.FULL_TIME:
|
| 841 |
continue
|
| 842 |
+
if off_map.get((emp.id, ds), False):
|
| 843 |
continue
|
| 844 |
if slot_block_map.get((emp.id, ds)) == slot:
|
| 845 |
continue
|
|
|
|
| 1099 |
logger.info(f" → 加入者平均{avg_si:.1f}回 / 未加入者平均{avg_non:.1f}回")
|
| 1100 |
if si_req_8h == 0 and si_emps_count > 0:
|
| 1101 |
logger.warning(" ⚠️ 社保加入PT全員が8h希望を提出していません。"
|
| 1102 |
+
"8時間のシフトパターンを提出するか、おまかせ(朝食・ディナー両方)で8hを設定してください。")
|
| 1103 |
|
| 1104 |
|
| 1105 |
def _log_assignment_summary(assignments, date_strs):
|
|
|
|
| 1203 |
for slot in slots:
|
| 1204 |
if emp.employment_type == EmploymentType.FULL_TIME:
|
| 1205 |
can_work = not off_map.get((emp.id, ds), False) \
|
|
|
|
| 1206 |
and slot_block_map.get((emp.id, ds)) != slot
|
| 1207 |
elif slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 1208 |
+
can_work = True
|
| 1209 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 1210 |
+
can_work = True
|
| 1211 |
else:
|
| 1212 |
can_work = req_map.get((emp.id, ds, slot.value), False)
|
| 1213 |
for pos in positions:
|
|
|
|
| 1501 |
or e.primary_position.value == pos.value):
|
| 1502 |
continue
|
| 1503 |
if e.employment_type == EmploymentType.FULL_TIME:
|
| 1504 |
+
# 正社員: off_mapのみで可否判断
|
| 1505 |
+
if off_map.get((e.id, ds), False):
|
| 1506 |
continue
|
| 1507 |
available.append(e)
|
| 1508 |
else:
|
routes/employees.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
from flask import Blueprint, render_template, request, redirect, url_for, flash, jsonify
|
| 2 |
from db import repositories as repo
|
| 3 |
-
from models.employee import Employee
|
| 4 |
-
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 5 |
|
| 6 |
bp = Blueprint("employees", __name__, url_prefix="/employees")
|
| 7 |
|
|
@@ -31,7 +31,6 @@ def new():
|
|
| 31 |
skill_levels=SkillLevel,
|
| 32 |
primary_positions=PrimaryPosition,
|
| 33 |
time_slots=TimeSlot,
|
| 34 |
-
dow_labels=DAY_OF_WEEK_LABELS,
|
| 35 |
)
|
| 36 |
|
| 37 |
|
|
@@ -56,7 +55,6 @@ def edit(emp_id):
|
|
| 56 |
skill_levels=SkillLevel,
|
| 57 |
primary_positions=PrimaryPosition,
|
| 58 |
time_slots=TimeSlot,
|
| 59 |
-
dow_labels=DAY_OF_WEEK_LABELS,
|
| 60 |
)
|
| 61 |
|
| 62 |
|
|
@@ -127,13 +125,6 @@ def bulk_action():
|
|
| 127 |
|
| 128 |
def _form_to_employee(emp_id):
|
| 129 |
f = request.form
|
| 130 |
-
patterns = []
|
| 131 |
-
for dow in range(7):
|
| 132 |
-
b = bool(f.get(f"fp_b_{dow}"))
|
| 133 |
-
d = bool(f.get(f"fp_d_{dow}"))
|
| 134 |
-
if b or d:
|
| 135 |
-
patterns.append(FixedPattern(dow, b, d))
|
| 136 |
-
|
| 137 |
pp_val = f.get("primary_position") or None
|
| 138 |
op_val = f.get("output_position") or None
|
| 139 |
pt_val = f.get("primary_timeslot") or None
|
|
@@ -168,7 +159,5 @@ def _form_to_employee(emp_id):
|
|
| 168 |
can_cleanup=can_cleanup,
|
| 169 |
always_available_breakfast=bool(f.get("always_available_breakfast")),
|
| 170 |
always_available_dinner=bool(f.get("always_available_dinner")),
|
| 171 |
-
fixed_patterns=patterns,
|
| 172 |
-
fixed_unavailable_dates=request.form.getlist("unavail_dates"),
|
| 173 |
is_active=True,
|
| 174 |
)
|
|
|
|
| 1 |
from flask import Blueprint, render_template, request, redirect, url_for, flash, jsonify
|
| 2 |
from db import repositories as repo
|
| 3 |
+
from models.employee import Employee
|
| 4 |
+
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 5 |
|
| 6 |
bp = Blueprint("employees", __name__, url_prefix="/employees")
|
| 7 |
|
|
|
|
| 31 |
skill_levels=SkillLevel,
|
| 32 |
primary_positions=PrimaryPosition,
|
| 33 |
time_slots=TimeSlot,
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
|
|
|
| 55 |
skill_levels=SkillLevel,
|
| 56 |
primary_positions=PrimaryPosition,
|
| 57 |
time_slots=TimeSlot,
|
|
|
|
| 58 |
)
|
| 59 |
|
| 60 |
|
|
|
|
| 125 |
|
| 126 |
def _form_to_employee(emp_id):
|
| 127 |
f = request.form
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
pp_val = f.get("primary_position") or None
|
| 129 |
op_val = f.get("output_position") or None
|
| 130 |
pt_val = f.get("primary_timeslot") or None
|
|
|
|
| 159 |
can_cleanup=can_cleanup,
|
| 160 |
always_available_breakfast=bool(f.get("always_available_breakfast")),
|
| 161 |
always_available_dinner=bool(f.get("always_available_dinner")),
|
|
|
|
|
|
|
| 162 |
is_active=True,
|
| 163 |
)
|
routes/settings_routes.py
CHANGED
|
@@ -184,7 +184,7 @@ def backup():
|
|
| 184 |
conn = Connection()
|
| 185 |
# google_tokens(Google連携のOAuthトークン)は機密情報のため意図的に対象外とする
|
| 186 |
tables = [
|
| 187 |
-
"employees",
|
| 188 |
"schedule_periods","shift_requests","shift_assignments",
|
| 189 |
"reservation_counts","customer_count_history","schedule_notes","staff_notes","cell_notes",
|
| 190 |
"shift_constraints","breakfast_band_constraints","app_settings","assignment_log",
|
|
@@ -224,7 +224,7 @@ def restore():
|
|
| 224 |
conn = Connection()
|
| 225 |
# 依存順でリストア(google_tokens はバックアップ対象外のため含めない)
|
| 226 |
restore_order = [
|
| 227 |
-
"employees",
|
| 228 |
"schedule_periods","shift_requests","shift_assignments",
|
| 229 |
"reservation_counts","customer_count_history","schedule_notes","staff_notes","cell_notes",
|
| 230 |
"shift_constraints","breakfast_band_constraints","app_settings","assignment_log",
|
|
|
|
| 184 |
conn = Connection()
|
| 185 |
# google_tokens(Google連携のOAuthトークン)は機密情報のため意図的に対象外とする
|
| 186 |
tables = [
|
| 187 |
+
"employees",
|
| 188 |
"schedule_periods","shift_requests","shift_assignments",
|
| 189 |
"reservation_counts","customer_count_history","schedule_notes","staff_notes","cell_notes",
|
| 190 |
"shift_constraints","breakfast_band_constraints","app_settings","assignment_log",
|
|
|
|
| 224 |
conn = Connection()
|
| 225 |
# 依存順でリストア(google_tokens はバックアップ対象外のため含めない)
|
| 226 |
restore_order = [
|
| 227 |
+
"employees",
|
| 228 |
"schedule_periods","shift_requests","shift_assignments",
|
| 229 |
"reservation_counts","customer_count_history","schedule_notes","staff_notes","cell_notes",
|
| 230 |
"shift_constraints","breakfast_band_constraints","app_settings","assignment_log",
|
routes/shifts.py
CHANGED
|
@@ -107,21 +107,6 @@ def input(period_id):
|
|
| 107 |
prev_idx = emp_idx - 1 if emp_idx > 0 else None
|
| 108 |
next_idx = emp_idx + 1 if emp_idx < len(employees) - 1 else None
|
| 109 |
|
| 110 |
-
# 固定シフト(曜日固定パターン)によるプリフィル
|
| 111 |
-
# 希望が未提出の日のみ、登録済みの固定パターンから初期値を補完する
|
| 112 |
-
if current_emp and current_emp.fixed_patterns:
|
| 113 |
-
from utils.shift_patterns import default_pattern_from_fixed
|
| 114 |
-
for d in dates:
|
| 115 |
-
key = (current_emp.id, str(d))
|
| 116 |
-
if key in req_map:
|
| 117 |
-
continue
|
| 118 |
-
fp = current_emp.get_pattern(d.weekday())
|
| 119 |
-
if not fp:
|
| 120 |
-
continue
|
| 121 |
-
pid = default_pattern_from_fixed(fp.breakfast, fp.dinner)
|
| 122 |
-
if pid:
|
| 123 |
-
req_map[key] = ShiftRequest(employee_id=current_emp.id, date=str(d), pattern_id=pid)
|
| 124 |
-
|
| 125 |
# 「おまかせ」スタッフのプリフィル
|
| 126 |
# 希望が未提出の日のみ、いつでも出勤可として全日「希望あり」を自動補完表示する
|
| 127 |
# (DBへの保存は行わず表示のみ。ソルバーは always_available_* フラグを直接参照して
|
|
|
|
| 107 |
prev_idx = emp_idx - 1 if emp_idx > 0 else None
|
| 108 |
next_idx = emp_idx + 1 if emp_idx < len(employees) - 1 else None
|
| 109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
# 「おまかせ」スタッフのプリフィル
|
| 111 |
# 希望が未提出の日のみ、いつでも出勤可として全日「希望あり」を自動補完表示する
|
| 112 |
# (DBへの保存は行わず表示のみ。ソルバーは always_available_* フラグを直接参照して
|
scripts/migrate_to_supabase.py
CHANGED
|
@@ -121,8 +121,6 @@ def main():
|
|
| 121 |
# 親テーブルを先に移行し、子テーブルを後に移行する
|
| 122 |
tables_to_migrate = [
|
| 123 |
"employees",
|
| 124 |
-
"fixed_patterns",
|
| 125 |
-
"fixed_unavailable_dates",
|
| 126 |
"schedule_periods",
|
| 127 |
"shift_requests",
|
| 128 |
"shift_assignments",
|
|
@@ -204,8 +202,6 @@ def main():
|
|
| 204 |
# SERIAL / PRIMARY KEY AUTOINCREMENT で定義されたテーブル
|
| 205 |
sequence_tables = [
|
| 206 |
"employees",
|
| 207 |
-
"fixed_patterns",
|
| 208 |
-
"fixed_unavailable_dates",
|
| 209 |
"schedule_periods",
|
| 210 |
"shift_requests",
|
| 211 |
"shift_assignments",
|
|
|
|
| 121 |
# 親テーブルを先に移行し、子テーブルを後に移行する
|
| 122 |
tables_to_migrate = [
|
| 123 |
"employees",
|
|
|
|
|
|
|
| 124 |
"schedule_periods",
|
| 125 |
"shift_requests",
|
| 126 |
"shift_assignments",
|
|
|
|
| 202 |
# SERIAL / PRIMARY KEY AUTOINCREMENT で定義されたテーブル
|
| 203 |
sequence_tables = [
|
| 204 |
"employees",
|
|
|
|
|
|
|
| 205 |
"schedule_periods",
|
| 206 |
"shift_requests",
|
| 207 |
"shift_assignments",
|
scripts/seed_test_data.py
CHANGED
|
@@ -17,7 +17,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
| 17 |
|
| 18 |
from db.database import initialize_db, get_connection
|
| 19 |
from db import repositories as repo
|
| 20 |
-
from models.employee import Employee
|
| 21 |
from models.schedule import SchedulePeriod, ShiftRequest, ShiftAssignment
|
| 22 |
from utils.constants import EmploymentType, SkillLevel, TimeSlot, Position
|
| 23 |
from utils.shift_patterns import ALL_PATTERNS, PATTERN_MAP, ShiftPattern
|
|
@@ -511,8 +511,6 @@ def reset_db():
|
|
| 511 |
conn.execute("DELETE FROM shift_assignments")
|
| 512 |
conn.execute("DELETE FROM shift_requests")
|
| 513 |
conn.execute("DELETE FROM schedule_periods")
|
| 514 |
-
conn.execute("DELETE FROM fixed_patterns")
|
| 515 |
-
conn.execute("DELETE FROM fixed_unavailable_dates")
|
| 516 |
conn.execute("DELETE FROM employees")
|
| 517 |
conn.commit()
|
| 518 |
conn.close()
|
|
|
|
| 17 |
|
| 18 |
from db.database import initialize_db, get_connection
|
| 19 |
from db import repositories as repo
|
| 20 |
+
from models.employee import Employee
|
| 21 |
from models.schedule import SchedulePeriod, ShiftRequest, ShiftAssignment
|
| 22 |
from utils.constants import EmploymentType, SkillLevel, TimeSlot, Position
|
| 23 |
from utils.shift_patterns import ALL_PATTERNS, PATTERN_MAP, ShiftPattern
|
|
|
|
| 511 |
conn.execute("DELETE FROM shift_assignments")
|
| 512 |
conn.execute("DELETE FROM shift_requests")
|
| 513 |
conn.execute("DELETE FROM schedule_periods")
|
|
|
|
|
|
|
| 514 |
conn.execute("DELETE FROM employees")
|
| 515 |
conn.commit()
|
| 516 |
conn.close()
|
templates/employees/form.html
CHANGED
|
@@ -274,66 +274,6 @@
|
|
| 274 |
</div>
|
| 275 |
</div>
|
| 276 |
|
| 277 |
-
<!-- 固定シフトパターン -->
|
| 278 |
-
<div class="card mb-3">
|
| 279 |
-
<div class="card-body">
|
| 280 |
-
<h6 class="card-title text-muted mb-3">固定シフトパターン(アルバイト/パート)
|
| 281 |
-
<span class="help-btn" data-bs-toggle="popover" data-bs-trigger="click" data-bs-placement="top"
|
| 282 |
-
data-bs-title="固定シフトパターン"
|
| 283 |
-
data-bs-content="毎週決まった曜日に出勤するスタッフに設定します。チェックした曜日は希望シフト提出と同様に扱われ、自動生成の対象になります。希望シフトで別の入力がある場合はそちらが優先されます。">?</span>
|
| 284 |
-
</h6>
|
| 285 |
-
<div class="table-responsive">
|
| 286 |
-
<table class="table table-sm table-bordered text-center mb-0">
|
| 287 |
-
<thead class="table-light">
|
| 288 |
-
<tr>
|
| 289 |
-
<th></th>
|
| 290 |
-
{% for d in dow_labels %}<th>{{ d }}</th>{% endfor %}
|
| 291 |
-
</tr>
|
| 292 |
-
</thead>
|
| 293 |
-
<tbody>
|
| 294 |
-
<tr id="fp-breakfast-row">
|
| 295 |
-
<td class="fw-semibold">朝食</td>
|
| 296 |
-
{% for i in range(7) %}
|
| 297 |
-
<td><input type="checkbox" name="fp_b_{{ i }}"
|
| 298 |
-
{{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).breakfast else '' }}></td>
|
| 299 |
-
{% endfor %}
|
| 300 |
-
</tr>
|
| 301 |
-
<tr id="fp-dinner-row">
|
| 302 |
-
<td class="fw-semibold">ディナー</td>
|
| 303 |
-
{% for i in range(7) %}
|
| 304 |
-
<td><input type="checkbox" name="fp_d_{{ i }}"
|
| 305 |
-
{{ 'checked' if emp and emp.get_pattern(i) and emp.get_pattern(i).dinner else '' }}></td>
|
| 306 |
-
{% endfor %}
|
| 307 |
-
</tr>
|
| 308 |
-
</tbody>
|
| 309 |
-
</table>
|
| 310 |
-
</div>
|
| 311 |
-
</div>
|
| 312 |
-
</div>
|
| 313 |
-
|
| 314 |
-
<!-- 固定不可日 -->
|
| 315 |
-
<div class="card mb-3">
|
| 316 |
-
<div class="card-body">
|
| 317 |
-
<h6 class="card-title text-muted mb-3">固定不可日</h6>
|
| 318 |
-
<div id="unavail-list" class="d-flex flex-wrap gap-2 mb-2">
|
| 319 |
-
{% for d in (emp.fixed_unavailable_dates if emp else []) %}
|
| 320 |
-
<div class="badge bg-secondary d-flex align-items-center gap-1 unavail-badge" style="font-size:.85rem">
|
| 321 |
-
<input type="hidden" name="unavail_dates" value="{{ d }}">
|
| 322 |
-
{{ d }}
|
| 323 |
-
<button type="button" class="btn-close btn-close-white btn-sm" style="font-size:.6rem"
|
| 324 |
-
onclick="this.closest('.unavail-badge').remove()"></button>
|
| 325 |
-
</div>
|
| 326 |
-
{% endfor %}
|
| 327 |
-
</div>
|
| 328 |
-
<div class="d-flex gap-2">
|
| 329 |
-
<input type="date" id="new-unavail-date" class="form-control form-control-sm" style="max-width:180px">
|
| 330 |
-
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="addUnavailDate()">
|
| 331 |
-
<i class="bi bi-plus"></i> 追加
|
| 332 |
-
</button>
|
| 333 |
-
</div>
|
| 334 |
-
</div>
|
| 335 |
-
</div>
|
| 336 |
-
|
| 337 |
<div class="d-grid gap-2">
|
| 338 |
<button type="submit" class="btn btn-primary btn-lg" data-loading="保存中…">
|
| 339 |
<i class="bi bi-check-lg me-1"></i>{{ '更新する' if emp else '登録する' }}
|
|
@@ -415,8 +355,6 @@ function onTimeslotChange() {
|
|
| 415 |
document.getElementById('aab-row').style.display = hideBreakfast ? 'none' : '';
|
| 416 |
document.getElementById('aad-row').style.display = hideDinner ? 'none' : '';
|
| 417 |
document.getElementById('omakase-both-row').style.display = (val === '') ? '' : 'none';
|
| 418 |
-
document.getElementById('fp-breakfast-row').style.display = hideBreakfast ? 'none' : '';
|
| 419 |
-
document.getElementById('fp-dinner-row').style.display = hideDinner ? 'none' : '';
|
| 420 |
}
|
| 421 |
|
| 422 |
onPositionChange();
|
|
@@ -427,21 +365,5 @@ function setBothOmakase() {
|
|
| 427 |
document.getElementById('aab').checked = true;
|
| 428 |
document.getElementById('aad').checked = true;
|
| 429 |
}
|
| 430 |
-
|
| 431 |
-
function addUnavailDate() {
|
| 432 |
-
const input = document.getElementById('new-unavail-date');
|
| 433 |
-
const val = input.value;
|
| 434 |
-
if (!val) return;
|
| 435 |
-
const existing = [...document.querySelectorAll('input[name="unavail_dates"]')].map(e => e.value);
|
| 436 |
-
if (existing.includes(val)) { input.value = ''; return; }
|
| 437 |
-
const badge = document.createElement('div');
|
| 438 |
-
badge.className = 'badge bg-secondary d-flex align-items-center gap-1 unavail-badge';
|
| 439 |
-
badge.style.fontSize = '.85rem';
|
| 440 |
-
badge.innerHTML = `<input type="hidden" name="unavail_dates" value="${val}">${val}
|
| 441 |
-
<button type="button" class="btn-close btn-close-white btn-sm" style="font-size:.6rem"
|
| 442 |
-
onclick="this.closest('.unavail-badge').remove()"></button>`;
|
| 443 |
-
document.getElementById('unavail-list').appendChild(badge);
|
| 444 |
-
input.value = '';
|
| 445 |
-
}
|
| 446 |
</script>
|
| 447 |
{% endblock %}
|
|
|
|
| 274 |
</div>
|
| 275 |
</div>
|
| 276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 277 |
<div class="d-grid gap-2">
|
| 278 |
<button type="submit" class="btn btn-primary btn-lg" data-loading="保存中…">
|
| 279 |
<i class="bi bi-check-lg me-1"></i>{{ '更新する' if emp else '登録する' }}
|
|
|
|
| 355 |
document.getElementById('aab-row').style.display = hideBreakfast ? 'none' : '';
|
| 356 |
document.getElementById('aad-row').style.display = hideDinner ? 'none' : '';
|
| 357 |
document.getElementById('omakase-both-row').style.display = (val === '') ? '' : 'none';
|
|
|
|
|
|
|
| 358 |
}
|
| 359 |
|
| 360 |
onPositionChange();
|
|
|
|
| 365 |
document.getElementById('aab').checked = true;
|
| 366 |
document.getElementById('aad').checked = true;
|
| 367 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
</script>
|
| 369 |
{% endblock %}
|
templates/help/index.html
CHANGED
|
@@ -225,13 +225,6 @@
|
|
| 225 |
</tbody>
|
| 226 |
</table>
|
| 227 |
|
| 228 |
-
<div class="sub-heading">固定シフトパターン(アルバイト/パート)</div>
|
| 229 |
-
<p style="font-size:.82rem">曜日ごとに「朝食」「ディナー」の出勤パターンを設定できます。<br>
|
| 230 |
-
固定パターンを設定したスタッフは、その曜日について希望シフト提出とほぼ同様に扱われます。</p>
|
| 231 |
-
|
| 232 |
-
<div class="sub-heading">固定不可日</div>
|
| 233 |
-
<p style="font-size:.82rem">特定の日付をあらかじめ「休み」として登録できます。シフト自動生成時にその日はアサインされません。</p>
|
| 234 |
-
|
| 235 |
<div class="sub-heading">アーカイブ・削除</div>
|
| 236 |
<table class="table table-sm table-bordered mb-3" style="font-size:.82rem">
|
| 237 |
<thead class="table-light"><tr><th>操作</th><th>内容</th></tr></thead>
|
|
|
|
| 225 |
</tbody>
|
| 226 |
</table>
|
| 227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
<div class="sub-heading">アーカイブ・削除</div>
|
| 229 |
<table class="table table-sm table-bordered mb-3" style="font-size:.82rem">
|
| 230 |
<thead class="table-light"><tr><th>操作</th><th>内容</th></tr></thead>
|
ui/employee_view.py
CHANGED
|
@@ -5,13 +5,12 @@ from PyQt6.QtWidgets import (
|
|
| 5 |
QTableWidgetItem, QHeaderView, QDialog, QFormLayout, QLineEdit,
|
| 6 |
QComboBox, QGroupBox, QCheckBox, QLabel, QMessageBox,
|
| 7 |
QCalendarWidget, QDialogButtonBox, QSizePolicy, QFrame,
|
| 8 |
-
QScrollArea
|
| 9 |
)
|
| 10 |
-
from PyQt6.QtCore import Qt, QDate
|
| 11 |
from PyQt6.QtGui import QFont, QColor
|
| 12 |
from db import repositories as repo
|
| 13 |
-
from models.employee import Employee
|
| 14 |
-
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 15 |
from utils.theme import theme
|
| 16 |
|
| 17 |
|
|
@@ -280,8 +279,7 @@ class EmployeeDialog(QDialog):
|
|
| 280 |
avail_layout.setSpacing(6)
|
| 281 |
avail_note = QLabel(
|
| 282 |
"チェックしたスタッフは希望シフトの提出が不要です。\n"
|
| 283 |
-
"対象の時間帯であれば毎日シフトに入れることができます。
|
| 284 |
-
"固定不可日のみ除外されます。"
|
| 285 |
)
|
| 286 |
avail_note.setWordWrap(True)
|
| 287 |
avail_note.setStyleSheet("font-size:11px; color:#6b7280;")
|
|
@@ -316,73 +314,6 @@ class EmployeeDialog(QDialog):
|
|
| 316 |
skill_layout.addRow("キッチン習熟度(ディナー)", self.kitchen_skill_dinner_combo)
|
| 317 |
layout.addWidget(skill_group)
|
| 318 |
|
| 319 |
-
# アルバイト/パート専用設定
|
| 320 |
-
self.parttime_group = QGroupBox("アルバイト/パート設定")
|
| 321 |
-
pt_layout = QVBoxLayout(self.parttime_group)
|
| 322 |
-
|
| 323 |
-
# 固定シフトパターン
|
| 324 |
-
pattern_label = QLabel("固定シフトパターン(毎週の出勤希望)")
|
| 325 |
-
pattern_label.setStyleSheet("font-weight:bold;")
|
| 326 |
-
pt_layout.addWidget(pattern_label)
|
| 327 |
-
|
| 328 |
-
pattern_grid = QGridLayout()
|
| 329 |
-
pattern_grid.setSpacing(6)
|
| 330 |
-
pattern_grid.addWidget(QLabel("曜日"), 0, 0)
|
| 331 |
-
pattern_grid.addWidget(QLabel("朝食"), 0, 1, Qt.AlignmentFlag.AlignCenter)
|
| 332 |
-
pattern_grid.addWidget(QLabel("ディナー"), 0, 2, Qt.AlignmentFlag.AlignCenter)
|
| 333 |
-
|
| 334 |
-
self.pattern_checks: list[tuple[QCheckBox, QCheckBox]] = []
|
| 335 |
-
for i, day in enumerate(DAY_OF_WEEK_LABELS):
|
| 336 |
-
lbl = QLabel(day)
|
| 337 |
-
cb_b = QCheckBox()
|
| 338 |
-
cb_d = QCheckBox()
|
| 339 |
-
pattern_grid.addWidget(lbl, i + 1, 0)
|
| 340 |
-
pattern_grid.addWidget(cb_b, i + 1, 1, Qt.AlignmentFlag.AlignCenter)
|
| 341 |
-
pattern_grid.addWidget(cb_d, i + 1, 2, Qt.AlignmentFlag.AlignCenter)
|
| 342 |
-
self.pattern_checks.append((cb_b, cb_d))
|
| 343 |
-
|
| 344 |
-
pt_layout.addLayout(pattern_grid)
|
| 345 |
-
|
| 346 |
-
note = QLabel("※ 固定パターンなしの場合はすべてチェックを外してください")
|
| 347 |
-
note.setStyleSheet("color:#6b7280; font-size:11px;")
|
| 348 |
-
pt_layout.addWidget(note)
|
| 349 |
-
|
| 350 |
-
layout.addWidget(self.parttime_group)
|
| 351 |
-
|
| 352 |
-
# 固定不可日
|
| 353 |
-
unavail_group = QGroupBox("固定不可日(出勤不可の日を登録)")
|
| 354 |
-
unavail_vl = QVBoxLayout(unavail_group)
|
| 355 |
-
unavail_vl.setSpacing(6)
|
| 356 |
-
|
| 357 |
-
add_row = QHBoxLayout()
|
| 358 |
-
self._unavail_date_edit = QDateEdit()
|
| 359 |
-
self._unavail_date_edit.setCalendarPopup(True)
|
| 360 |
-
self._unavail_date_edit.setDate(QDate.currentDate())
|
| 361 |
-
self._unavail_date_edit.setDisplayFormat("yyyy/MM/dd")
|
| 362 |
-
btn_add_unavail = QPushButton("追加")
|
| 363 |
-
btn_add_unavail.setFixedWidth(56)
|
| 364 |
-
btn_add_unavail.clicked.connect(self._add_unavail_date)
|
| 365 |
-
add_row.addWidget(QLabel("日付:"))
|
| 366 |
-
add_row.addWidget(self._unavail_date_edit)
|
| 367 |
-
add_row.addWidget(btn_add_unavail)
|
| 368 |
-
add_row.addStretch()
|
| 369 |
-
unavail_vl.addLayout(add_row)
|
| 370 |
-
|
| 371 |
-
self._unavail_list = QListWidget()
|
| 372 |
-
self._unavail_list.setMaximumHeight(90)
|
| 373 |
-
self._unavail_list.setSelectionMode(QListWidget.SelectionMode.MultiSelection)
|
| 374 |
-
unavail_vl.addWidget(self._unavail_list)
|
| 375 |
-
|
| 376 |
-
btn_remove_row = QHBoxLayout()
|
| 377 |
-
btn_remove_row.addStretch()
|
| 378 |
-
btn_remove_unavail = QPushButton("選択した日を削除")
|
| 379 |
-
btn_remove_unavail.setFixedHeight(28)
|
| 380 |
-
btn_remove_unavail.clicked.connect(self._remove_unavail_dates)
|
| 381 |
-
btn_remove_row.addWidget(btn_remove_unavail)
|
| 382 |
-
unavail_vl.addLayout(btn_remove_row)
|
| 383 |
-
|
| 384 |
-
layout.addWidget(unavail_group)
|
| 385 |
-
|
| 386 |
# ボタン
|
| 387 |
buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel)
|
| 388 |
buttons.button(QDialogButtonBox.StandardButton.Save).setText("保存")
|
|
@@ -395,8 +326,6 @@ class EmployeeDialog(QDialog):
|
|
| 395 |
self._on_timeslot_changed()
|
| 396 |
|
| 397 |
def _on_type_changed(self):
|
| 398 |
-
is_part = self.emp_type_combo.currentData() == EmploymentType.PART_TIME
|
| 399 |
-
self.parttime_group.setVisible(is_part)
|
| 400 |
self.adjustSize()
|
| 401 |
|
| 402 |
def _on_timeslot_changed(self):
|
|
@@ -408,18 +337,6 @@ class EmployeeDialog(QDialog):
|
|
| 408 |
self.can_cleanup_check.setChecked(False)
|
| 409 |
self.adjustSize()
|
| 410 |
|
| 411 |
-
def _add_unavail_date(self):
|
| 412 |
-
ds = self._unavail_date_edit.date().toString("yyyy-MM-dd")
|
| 413 |
-
# 重複チェック
|
| 414 |
-
existing = [self._unavail_list.item(i).text() for i in range(self._unavail_list.count())]
|
| 415 |
-
if ds not in existing:
|
| 416 |
-
self._unavail_list.addItem(ds)
|
| 417 |
-
self._unavail_list.sortItems()
|
| 418 |
-
|
| 419 |
-
def _remove_unavail_dates(self):
|
| 420 |
-
for item in self._unavail_list.selectedItems():
|
| 421 |
-
self._unavail_list.takeItem(self._unavail_list.row(item))
|
| 422 |
-
|
| 423 |
def _load_employee(self, emp: Employee):
|
| 424 |
self.name_edit.setText(emp.name)
|
| 425 |
idx = self.emp_type_combo.findData(emp.employment_type)
|
|
@@ -443,15 +360,6 @@ class EmployeeDialog(QDialog):
|
|
| 443 |
idx_kd = self.kitchen_skill_dinner_combo.findData(emp.kitchen_skill_dinner)
|
| 444 |
self.kitchen_skill_dinner_combo.setCurrentIndex(idx_kd)
|
| 445 |
|
| 446 |
-
for i, (cb_b, cb_d) in enumerate(self.pattern_checks):
|
| 447 |
-
p = emp.get_pattern(i)
|
| 448 |
-
cb_b.setChecked(p.breakfast if p else False)
|
| 449 |
-
cb_d.setChecked(p.dinner if p else False)
|
| 450 |
-
|
| 451 |
-
self._unavail_list.clear()
|
| 452 |
-
for ds in sorted(emp.fixed_unavailable_dates):
|
| 453 |
-
self._unavail_list.addItem(ds)
|
| 454 |
-
|
| 455 |
def _on_save(self):
|
| 456 |
name = self.name_edit.text().strip()
|
| 457 |
if not name:
|
|
@@ -474,17 +382,7 @@ class EmployeeDialog(QDialog):
|
|
| 474 |
kitchen_skill_breakfast = self.kitchen_skill_breakfast_combo.currentData()
|
| 475 |
kitchen_skill_dinner = self.kitchen_skill_dinner_combo.currentData()
|
| 476 |
|
| 477 |
-
patterns = []
|
| 478 |
-
if emp_type == EmploymentType.PART_TIME:
|
| 479 |
-
for i, (cb_b, cb_d) in enumerate(self.pattern_checks):
|
| 480 |
-
if cb_b.isChecked() or cb_d.isChecked():
|
| 481 |
-
patterns.append(FixedPattern(i, cb_b.isChecked(), cb_d.isChecked()))
|
| 482 |
-
|
| 483 |
existing_id = self.employee.id if self.employee else None
|
| 484 |
-
unavail_dates = [
|
| 485 |
-
self._unavail_list.item(i).text()
|
| 486 |
-
for i in range(self._unavail_list.count())
|
| 487 |
-
]
|
| 488 |
|
| 489 |
self.employee = Employee(
|
| 490 |
id=existing_id,
|
|
@@ -501,7 +399,5 @@ class EmployeeDialog(QDialog):
|
|
| 501 |
always_available_breakfast=always_avail_b,
|
| 502 |
always_available_dinner=always_avail_d,
|
| 503 |
primary_timeslot=primary_timeslot,
|
| 504 |
-
fixed_patterns=patterns,
|
| 505 |
-
fixed_unavailable_dates=unavail_dates,
|
| 506 |
)
|
| 507 |
self.accept()
|
|
|
|
| 5 |
QTableWidgetItem, QHeaderView, QDialog, QFormLayout, QLineEdit,
|
| 6 |
QComboBox, QGroupBox, QCheckBox, QLabel, QMessageBox,
|
| 7 |
QCalendarWidget, QDialogButtonBox, QSizePolicy, QFrame,
|
| 8 |
+
QScrollArea
|
| 9 |
)
|
|
|
|
| 10 |
from PyQt6.QtGui import QFont, QColor
|
| 11 |
from db import repositories as repo
|
| 12 |
+
from models.employee import Employee
|
| 13 |
+
from utils.constants import EmploymentType, SkillLevel, PrimaryPosition, TimeSlot
|
| 14 |
from utils.theme import theme
|
| 15 |
|
| 16 |
|
|
|
|
| 279 |
avail_layout.setSpacing(6)
|
| 280 |
avail_note = QLabel(
|
| 281 |
"チェックしたスタッフは希望シフトの提出が不要です。\n"
|
| 282 |
+
"対象の時間帯であれば毎日シフトに入れることができます。"
|
|
|
|
| 283 |
)
|
| 284 |
avail_note.setWordWrap(True)
|
| 285 |
avail_note.setStyleSheet("font-size:11px; color:#6b7280;")
|
|
|
|
| 314 |
skill_layout.addRow("キッチン習熟度(ディナー)", self.kitchen_skill_dinner_combo)
|
| 315 |
layout.addWidget(skill_group)
|
| 316 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
# ボタン
|
| 318 |
buttons = QDialogButtonBox(QDialogButtonBox.StandardButton.Save | QDialogButtonBox.StandardButton.Cancel)
|
| 319 |
buttons.button(QDialogButtonBox.StandardButton.Save).setText("保存")
|
|
|
|
| 326 |
self._on_timeslot_changed()
|
| 327 |
|
| 328 |
def _on_type_changed(self):
|
|
|
|
|
|
|
| 329 |
self.adjustSize()
|
| 330 |
|
| 331 |
def _on_timeslot_changed(self):
|
|
|
|
| 337 |
self.can_cleanup_check.setChecked(False)
|
| 338 |
self.adjustSize()
|
| 339 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 340 |
def _load_employee(self, emp: Employee):
|
| 341 |
self.name_edit.setText(emp.name)
|
| 342 |
idx = self.emp_type_combo.findData(emp.employment_type)
|
|
|
|
| 360 |
idx_kd = self.kitchen_skill_dinner_combo.findData(emp.kitchen_skill_dinner)
|
| 361 |
self.kitchen_skill_dinner_combo.setCurrentIndex(idx_kd)
|
| 362 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 363 |
def _on_save(self):
|
| 364 |
name = self.name_edit.text().strip()
|
| 365 |
if not name:
|
|
|
|
| 382 |
kitchen_skill_breakfast = self.kitchen_skill_breakfast_combo.currentData()
|
| 383 |
kitchen_skill_dinner = self.kitchen_skill_dinner_combo.currentData()
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
existing_id = self.employee.id if self.employee else None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
self.employee = Employee(
|
| 388 |
id=existing_id,
|
|
|
|
| 399 |
always_available_breakfast=always_avail_b,
|
| 400 |
always_available_dinner=always_avail_d,
|
| 401 |
primary_timeslot=primary_timeslot,
|
|
|
|
|
|
|
| 402 |
)
|
| 403 |
self.accept()
|
ui/help_view.py
CHANGED
|
@@ -31,8 +31,6 @@ _HELP_HTML = """
|
|
| 31 |
正社員はどちらでも可(毎回希望入力不要)、アルバイト/パートは希望に従います。</li>
|
| 32 |
<li><b>習熟度</b> — ホール・キッチンそれぞれに設定します。<br>
|
| 33 |
<b>リーダー</b> ≫ <b>ベテラン</b>(熟練者カウント対象)≫ <b>メンバー</b> ≫ <b>ビギナー</b></li>
|
| 34 |
-
<li><b>固定シフト(アルバイト/パートのみ)</b> — 毎週決まった曜日・時間帯に出るスタッフは固定パターンを設定すると希望入力を省略できます。</li>
|
| 35 |
-
<li><b>固定不可日</b> — 特定日(イベント・試験等)に出られない日を登録します。</li>
|
| 36 |
<li><b>アーカイブ</b> — 退職・長期休暇のスタッフは「削除」でアーカイブ化できます。過去のシフトデータはそのまま残ります。</li>
|
| 37 |
</ul>
|
| 38 |
|
|
|
|
| 31 |
正社員はどちらでも可(毎回希望入力不要)、アルバイト/パートは希望に従います。</li>
|
| 32 |
<li><b>習熟度</b> — ホール・キッチンそれぞれに設定します。<br>
|
| 33 |
<b>リーダー</b> ≫ <b>ベテラン</b>(熟練者カウント対象)≫ <b>メンバー</b> ≫ <b>ビギナー</b></li>
|
|
|
|
|
|
|
| 34 |
<li><b>アーカイブ</b> — 退職・長期休暇のスタッフは「削除」でアーカイブ化できます。過去のシフトデータはそのまま残ります。</li>
|
| 35 |
</ul>
|
| 36 |
|
ui/schedule_view.py
CHANGED
|
@@ -579,11 +579,11 @@ class ScheduleView(QWidget):
|
|
| 579 |
reinf_start = result[2] if result else None
|
| 580 |
reinf_end = result[3] if result else None
|
| 581 |
req = self._requests.get((emp.id, ds))
|
| 582 |
-
# 常時出勤可スタッフ:
|
| 583 |
if slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 584 |
-
can_work =
|
| 585 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 586 |
-
can_work =
|
| 587 |
else:
|
| 588 |
can_work = (req[0] if slot == TimeSlot.BREAKFAST else req[1]) if req else False
|
| 589 |
|
|
|
|
| 579 |
reinf_start = result[2] if result else None
|
| 580 |
reinf_end = result[3] if result else None
|
| 581 |
req = self._requests.get((emp.id, ds))
|
| 582 |
+
# 常時出勤可スタッフ: can_work=True
|
| 583 |
if slot == TimeSlot.BREAKFAST and emp.always_available_breakfast:
|
| 584 |
+
can_work = True
|
| 585 |
elif slot == TimeSlot.DINNER and emp.always_available_dinner:
|
| 586 |
+
can_work = True
|
| 587 |
else:
|
| 588 |
can_work = (req[0] if slot == TimeSlot.BREAKFAST else req[1]) if req else False
|
| 589 |
|
ui/shift_input_view.py
CHANGED
|
@@ -12,7 +12,7 @@ from PyQt6.QtGui import QFont, QColor, QBrush, QKeySequence, QShortcut
|
|
| 12 |
from db import repositories as repo
|
| 13 |
from models.schedule import SchedulePeriod, ShiftRequest
|
| 14 |
from utils.constants import DAY_OF_WEEK_LABELS
|
| 15 |
-
from utils.shift_patterns import ALL_PATTERNS, PATTERN_MAP
|
| 16 |
from utils.theme import theme
|
| 17 |
|
| 18 |
|
|
@@ -106,10 +106,6 @@ class _PatternCellWidget(QWidget):
|
|
| 106 |
end = parts[1] if len(parts) >= 2 else None
|
| 107 |
return start, end
|
| 108 |
|
| 109 |
-
def set_enabled(self, enabled: bool):
|
| 110 |
-
self.combo.setEnabled(enabled)
|
| 111 |
-
self.custom_edit.setEnabled(enabled)
|
| 112 |
-
|
| 113 |
|
| 114 |
class ShiftInputView(QWidget):
|
| 115 |
period_changed = pyqtSignal(int) # 期間変更を MainWindow に通知 (item 1)
|
|
@@ -321,14 +317,14 @@ class ShiftInputView(QWidget):
|
|
| 321 |
cell = self._pattern_cells.get(date_str)
|
| 322 |
if cell and cell.combo.isEnabled() and combo_index < cell.combo.count():
|
| 323 |
cell.combo.setCurrentIndex(combo_index)
|
| 324 |
-
self._apply_row_color(row, date_str
|
| 325 |
|
| 326 |
def _on_combo_number_key(self, combo_index: int, date_str: str, row: int):
|
| 327 |
"""コンボが number_pressed シグナルを emit したときの処理"""
|
| 328 |
cell = self._pattern_cells.get(date_str)
|
| 329 |
if cell and cell.combo.isEnabled() and combo_index < cell.combo.count():
|
| 330 |
cell.combo.setCurrentIndex(combo_index)
|
| 331 |
-
self._apply_row_color(row, date_str
|
| 332 |
|
| 333 |
def _apply_styles(self):
|
| 334 |
c = theme.c
|
|
@@ -460,7 +456,7 @@ class ShiftInputView(QWidget):
|
|
| 460 |
cell = self._pattern_cells.get(ds)
|
| 461 |
if cell and cell.combo.isEnabled():
|
| 462 |
cell.set_pattern(pattern_id)
|
| 463 |
-
self._apply_row_color(row, ds
|
| 464 |
|
| 465 |
def _on_delete_period(self):
|
| 466 |
p = self.period_combo.currentData()
|
|
@@ -638,7 +634,7 @@ class ShiftInputView(QWidget):
|
|
| 638 |
c = theme.c
|
| 639 |
self._always_avail_banner.setText(
|
| 640 |
f"ℹ️ {emp.name}さんは【{'・'.join(slots_avail)}】が常時出勤可のため"
|
| 641 |
-
"希望提出は不要です。
|
| 642 |
)
|
| 643 |
self._always_avail_banner.setStyleSheet(
|
| 644 |
f"background:#EFF6FF; border:1px solid #BFDBFE; border-radius:4px; "
|
|
@@ -672,25 +668,13 @@ class ShiftInputView(QWidget):
|
|
| 672 |
self.table.setItem(row, 0, date_item)
|
| 673 |
|
| 674 |
# ── パターン選択セル ──
|
| 675 |
-
is_unavail = date_str in emp.fixed_unavailable_dates
|
| 676 |
req = self._requests.get((emp.id, date_str))
|
| 677 |
|
| 678 |
cell = _PatternCellWidget()
|
| 679 |
-
cell.set_enabled(not is_unavail)
|
| 680 |
|
| 681 |
-
if
|
| 682 |
-
# 固定不可日: 休みのまま
|
| 683 |
-
cell.set_pattern(None)
|
| 684 |
-
cell.combo.setToolTip("固定不可日")
|
| 685 |
-
elif req is not None:
|
| 686 |
# 保存済みデータを復元
|
| 687 |
cell.set_pattern(req.pattern_id, req.custom_start, req.custom_end)
|
| 688 |
-
elif emp.has_fixed_pattern():
|
| 689 |
-
# 固定パターンからデフォルトを設定
|
| 690 |
-
fp = emp.get_pattern(dow)
|
| 691 |
-
if fp:
|
| 692 |
-
default_pid = default_pattern_from_fixed(fp.breakfast, fp.dinner)
|
| 693 |
-
cell.set_pattern(default_pid)
|
| 694 |
|
| 695 |
# コンボの数字キーシグナルをビューのハンドラに接続
|
| 696 |
cell.combo.number_pressed.connect(
|
|
@@ -705,13 +689,8 @@ class ShiftInputView(QWidget):
|
|
| 705 |
note_item.setFlags(note_item.flags() | Qt.ItemFlag.ItemIsEditable)
|
| 706 |
self.table.setItem(row, 2, note_item)
|
| 707 |
|
| 708 |
-
# 不可日はグレーアウト
|
| 709 |
-
if is_unavail:
|
| 710 |
-
date_item.setBackground(QBrush(QColor(theme.c["cell_none"])))
|
| 711 |
-
note_item.setBackground(QBrush(QColor(theme.c["cell_none"])))
|
| 712 |
-
|
| 713 |
# 行の背景色でパターン種別を視覚化
|
| 714 |
-
self._apply_row_color(row, date_str
|
| 715 |
|
| 716 |
self.table.setRowHeight(row, 38)
|
| 717 |
|
|
@@ -719,10 +698,8 @@ class ShiftInputView(QWidget):
|
|
| 719 |
self._saved_snapshot = self._current_snapshot()
|
| 720 |
self._refresh_history()
|
| 721 |
|
| 722 |
-
def _apply_row_color(self, row: int, date_str: str
|
| 723 |
"""選択パターンに応じて行背景を更新(変更時にも呼べるよう分離)"""
|
| 724 |
-
if is_unavail:
|
| 725 |
-
return
|
| 726 |
cell = self._pattern_cells.get(date_str)
|
| 727 |
if not cell:
|
| 728 |
return
|
|
|
|
| 12 |
from db import repositories as repo
|
| 13 |
from models.schedule import SchedulePeriod, ShiftRequest
|
| 14 |
from utils.constants import DAY_OF_WEEK_LABELS
|
| 15 |
+
from utils.shift_patterns import ALL_PATTERNS, PATTERN_MAP
|
| 16 |
from utils.theme import theme
|
| 17 |
|
| 18 |
|
|
|
|
| 106 |
end = parts[1] if len(parts) >= 2 else None
|
| 107 |
return start, end
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
class ShiftInputView(QWidget):
|
| 111 |
period_changed = pyqtSignal(int) # 期間変更を MainWindow に通知 (item 1)
|
|
|
|
| 317 |
cell = self._pattern_cells.get(date_str)
|
| 318 |
if cell and cell.combo.isEnabled() and combo_index < cell.combo.count():
|
| 319 |
cell.combo.setCurrentIndex(combo_index)
|
| 320 |
+
self._apply_row_color(row, date_str)
|
| 321 |
|
| 322 |
def _on_combo_number_key(self, combo_index: int, date_str: str, row: int):
|
| 323 |
"""コンボが number_pressed シグナルを emit したときの処理"""
|
| 324 |
cell = self._pattern_cells.get(date_str)
|
| 325 |
if cell and cell.combo.isEnabled() and combo_index < cell.combo.count():
|
| 326 |
cell.combo.setCurrentIndex(combo_index)
|
| 327 |
+
self._apply_row_color(row, date_str)
|
| 328 |
|
| 329 |
def _apply_styles(self):
|
| 330 |
c = theme.c
|
|
|
|
| 456 |
cell = self._pattern_cells.get(ds)
|
| 457 |
if cell and cell.combo.isEnabled():
|
| 458 |
cell.set_pattern(pattern_id)
|
| 459 |
+
self._apply_row_color(row, ds)
|
| 460 |
|
| 461 |
def _on_delete_period(self):
|
| 462 |
p = self.period_combo.currentData()
|
|
|
|
| 634 |
c = theme.c
|
| 635 |
self._always_avail_banner.setText(
|
| 636 |
f"ℹ️ {emp.name}さんは【{'・'.join(slots_avail)}】が常時出勤可のため"
|
| 637 |
+
"希望提出は不要です。"
|
| 638 |
)
|
| 639 |
self._always_avail_banner.setStyleSheet(
|
| 640 |
f"background:#EFF6FF; border:1px solid #BFDBFE; border-radius:4px; "
|
|
|
|
| 668 |
self.table.setItem(row, 0, date_item)
|
| 669 |
|
| 670 |
# ── パターン選択セル ──
|
|
|
|
| 671 |
req = self._requests.get((emp.id, date_str))
|
| 672 |
|
| 673 |
cell = _PatternCellWidget()
|
|
|
|
| 674 |
|
| 675 |
+
if req is not None:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 676 |
# 保存済みデータを復元
|
| 677 |
cell.set_pattern(req.pattern_id, req.custom_start, req.custom_end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 678 |
|
| 679 |
# コンボの数字キーシグナルをビューのハンドラに接続
|
| 680 |
cell.combo.number_pressed.connect(
|
|
|
|
| 689 |
note_item.setFlags(note_item.flags() | Qt.ItemFlag.ItemIsEditable)
|
| 690 |
self.table.setItem(row, 2, note_item)
|
| 691 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 692 |
# 行の背景色でパターン種別を視覚化
|
| 693 |
+
self._apply_row_color(row, date_str)
|
| 694 |
|
| 695 |
self.table.setRowHeight(row, 38)
|
| 696 |
|
|
|
|
| 698 |
self._saved_snapshot = self._current_snapshot()
|
| 699 |
self._refresh_history()
|
| 700 |
|
| 701 |
+
def _apply_row_color(self, row: int, date_str: str):
|
| 702 |
"""選択パターンに応じて行背景を更新(変更時にも呼べるよう分離)"""
|
|
|
|
|
|
|
| 703 |
cell = self._pattern_cells.get(date_str)
|
| 704 |
if not cell:
|
| 705 |
return
|