提交
This commit is contained in:
1 parent
9345cf4ad8
commit
c3bd2c00ae
51 files changed
+14486
-15765
No files matched your search
+18
-11
@@ -66,10 +66,14 @@ def list_plans(
|
||||
created_from: Optional[str] = Query(default=None, alias="createdFrom", description="创建开始日期"),
|
||||
created_to: Optional[str] = Query(default=None, alias="createdTo", description="创建结束日期"),
|
||||
start_date_from: Optional[str] = Query(
|
||||
default=None, alias="startDateFrom", description="计划起始日期开始"
|
||||
default=None,
|
||||
alias="startDateFrom",
|
||||
description="筛选区间开始:与计划有效期(起始~截止)有交集",
|
||||
),
|
||||
start_date_to: Optional[str] = Query(
|
||||
default=None, alias="startDateTo", description="计划起始日期结束"
|
||||
default=None,
|
||||
alias="startDateTo",
|
||||
description="筛选区间结束:与计划有效期(起始~截止)有交集",
|
||||
),
|
||||
db: Session = Depends(get_db),
|
||||
user: DbUserContext = Depends(get_db_current_user),
|
||||
@@ -110,15 +114,18 @@ def list_plans(
|
||||
if created_to:
|
||||
query = query.filter(DbPurchasePlan.create_time <= f"{created_to} 23:59:59")
|
||||
|
||||
if start_date_from:
|
||||
start_from = parse_date_str(start_date_from)
|
||||
if start_from:
|
||||
query = query.filter(DbPurchasePlan.start_date >= start_from)
|
||||
|
||||
if start_date_to:
|
||||
start_to = parse_date_str(start_date_to)
|
||||
if start_to:
|
||||
query = query.filter(DbPurchasePlan.start_date <= start_to)
|
||||
# 按计划有效期与筛选区间重叠:start_date <= range_to 且 end_date >= range_from
|
||||
# (空起始/截止视为该侧无界,与三方填写页「当天是否在有效期内」语义一致)
|
||||
range_from = parse_date_str(start_date_from) if start_date_from else None
|
||||
range_to = parse_date_str(start_date_to) if start_date_to else None
|
||||
if range_to:
|
||||
query = query.filter(
|
||||
or_(DbPurchasePlan.start_date.is_(None), DbPurchasePlan.start_date <= range_to)
|
||||
)
|
||||
if range_from:
|
||||
query = query.filter(
|
||||
or_(DbPurchasePlan.end_date.is_(None), DbPurchasePlan.end_date >= range_from)
|
||||
)
|
||||
|
||||
query = apply_db_scope(query, DbPurchasePlan, user, db, tenant_no)
|
||||
plans = query.all()
|
||||
|
||||
@@ -51,7 +51,7 @@ class DutySlot(Base):
|
||||
capacity = Column(Integer, nullable=False, default=1, comment="名额")
|
||||
tenant_no = Column(String(64), nullable=False, default="shanxia2.0", comment="租户编号")
|
||||
order_num = Column(Integer, nullable=True, comment="排序号")
|
||||
remark = Column(String(500), nullable=True, comment="备注")
|
||||
remark = Column(String(500), nullable=True, comment="班次工作安排")
|
||||
create_by = Column(String(64), nullable=True, comment="创建者")
|
||||
create_dept_id = Column(String(64), nullable=False, default="", comment="创建部门")
|
||||
create_time = Column(DateTime, nullable=False, default=datetime.now, comment="创建时间")
|
||||
|
||||
@@ -20,6 +20,7 @@ class DutyAssignmentIn(BaseModel):
|
||||
class DutySlotSaveIn(BaseModel):
|
||||
shiftType: ShiftType
|
||||
capacity: int = Field(ge=1, le=99)
|
||||
remark: Optional[str] = Field(default=None, max_length=500)
|
||||
assignments: List[DutyAssignmentIn] = []
|
||||
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ def _slot_dict(slot: DutySlot, assignments: Sequence[DutyAssignment]) -> Dict[st
|
||||
"shiftLabel": SHIFT_LABELS.get(slot.shift_type, slot.shift_type),
|
||||
"capacity": slot.capacity,
|
||||
"taken": len(active),
|
||||
"remark": (slot.remark or "").strip() or None,
|
||||
"assignments": [_assignment_dict(a) for a in active],
|
||||
}
|
||||
|
||||
@@ -290,6 +291,7 @@ def save_day(
|
||||
for slot_in in body.slots:
|
||||
order += 1
|
||||
slot = existing_by_type.get(slot_in.shiftType)
|
||||
slot_remark = (slot_in.remark or "").strip() or None
|
||||
# 已有 slot 上历史 assign 用户可再保存(D4);新建 slot 必须具备值班人员角色(D7)
|
||||
grandfathered_user_ids: set = set()
|
||||
if slot is None:
|
||||
@@ -298,6 +300,7 @@ def save_day(
|
||||
duty_day_id=day.id,
|
||||
shift_type=slot_in.shiftType,
|
||||
capacity=slot_in.capacity,
|
||||
remark=slot_remark,
|
||||
tenant_no=tenant_no,
|
||||
order_num=order,
|
||||
create_by=user_id,
|
||||
@@ -335,6 +338,7 @@ def save_day(
|
||||
f"超过名额 {slot_in.capacity},请先删人再缩容"
|
||||
)
|
||||
slot.capacity = slot_in.capacity
|
||||
slot.remark = slot_remark
|
||||
slot.order_num = order
|
||||
slot.update_by = user_id
|
||||
slot.update_time = now
|
||||
|
||||
Reference in new issue
Block a user