- 职位序列改取 pt_staff_stru.first_type_id,按 rf_s_Core_Post_pt_post_type_Select_v3_1 字典转名称 - 星级改按 star_level_sp_cq37du 字典解析(ext_1=见习/ext_2=正式/ext_13=代理),实时结果不全时回退全量导出 - 调薪但无起薪记录:与平台同口径「该员工没起薪,无需调薪」,记跳过而非待人工 - 入职/再次入职当天又借调:借调待办调 insertHrWageBaseStaffChange.mc(changeIds[])设置忽略,试算只标记待忽略 - 花名册实时查询补专用角色集、按页拉全
131 lines
5.7 KiB
Python
131 lines
5.7 KiB
Python
# -*- coding: utf-8 -*-
|
||
"""处理动作判定:按花名册「职位序列」限定范围并映射工资账套。
|
||
|
||
规则:
|
||
- 只处理 门店服务序列 / 门店技师序列 / 门店管理序列(现网「经营系管理序列」等同门店管理序列);
|
||
- 序列 → 账套:服务账套 / 技师账套 / 管理账套;
|
||
- 异动类型=离职 → 跳过;星级为高级/资深(标准表未定义档位)→ 跳过;入职类 → 起薪;其他 → 调薪(已起薪才可调);
|
||
- 入职/再次入职当天又借调 → 借调那条记录无需调薪,调 HR「设置忽略」接口把它忽略(不留待办);
|
||
- 调薪但查不到起薪记录 → 与平台同口径:未起薪、无需调薪,跳过(不提交、不算异常);
|
||
- 调薪时新账套与现有账套不一致 → 换账套。
|
||
"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Optional
|
||
|
||
from .. import config
|
||
|
||
ACTION_START = "起薪"
|
||
ACTION_CHANGE = "调薪"
|
||
ACTION_IGNORE = "忽略"
|
||
ACTION_SKIP = "跳过"
|
||
ACTION_PENDING = "待核对"
|
||
|
||
|
||
def same_day_borrow_ids(rows) -> set:
|
||
"""入职/再次入职当天又有借调待办的,返回需要「设置忽略」的 CHANGE_ID 集合。
|
||
|
||
判定:同一工号存在入职类待办(6/14/102),且其 CHANGE_DATE 与某条借调(ext_1)
|
||
待办的 CHANGE_DATE 完全相同。这类借调是入职当天的组织和岗位落地动作,不应再生成
|
||
调薪待办,HR 里的处理方式就是「设置忽略」。
|
||
"""
|
||
start_dates = {}
|
||
for row in rows or []:
|
||
code = config.text(row.get("base_code"))
|
||
if code and config.text(row.get("CHANGE_TYPE")) in config.START_TYPES:
|
||
start_dates.setdefault(code, set()).add(config.text(row.get("CHANGE_DATE")))
|
||
result = set()
|
||
for row in rows or []:
|
||
code = config.text(row.get("base_code"))
|
||
if not code or config.text(row.get("CHANGE_TYPE")) not in config.BORROW_CHANGE_TYPES:
|
||
continue
|
||
if config.text(row.get("CHANGE_DATE")) not in start_dates.get(code, set()):
|
||
continue
|
||
change_id = config.text(row.get("CHANGE_ID"))
|
||
if change_id:
|
||
result.add(change_id)
|
||
return result
|
||
|
||
|
||
def _account_name(account_id: str, accounts: dict) -> str:
|
||
for name, info in accounts.items():
|
||
if info.get("id") == account_id:
|
||
return name
|
||
return ""
|
||
|
||
|
||
def decide(row: dict, started: Optional[dict], accounts: dict, sequence: str = "",
|
||
star: str = "", ignore: bool = False) -> dict:
|
||
"""返回 {action, reason, account, account_id, switch_account, change_wage_type}。
|
||
|
||
Args:
|
||
ignore: 该待办已被判定为「入职当天借调」(见 :func:`same_day_borrow_ids`),
|
||
走「设置忽略」而不是调薪。
|
||
"""
|
||
unit = config.text(row.get("BELONG_UNIT_ORG_NAME"))
|
||
change_type = config.text(row.get("CHANGE_TYPE"))
|
||
change_name = config.CHANGE_TYPE_NAMES.get(change_type, change_type)
|
||
|
||
result = {"action": ACTION_SKIP, "reason": "", "account": "", "account_id": "",
|
||
"switch_account": False, "change_wage_type": 0,
|
||
"change_type_name": change_name, "sequence": config.text(sequence)}
|
||
|
||
if unit not in config.BELONG_UNITS:
|
||
result["reason"] = f"单位不符({unit or '空'}),不在金色印象/金色湖畔事业部"
|
||
return result
|
||
if change_type in config.SKIP_TYPES:
|
||
result["reason"] = "异动类型=离职,按要求不处理"
|
||
return result
|
||
|
||
seq = config.text(sequence)
|
||
account = config.sequence_account(seq)
|
||
if not seq:
|
||
result["action"] = ACTION_PENDING
|
||
result["reason"] = "花名册未查到职位序列,需人工确认"
|
||
return result
|
||
if not account:
|
||
result["reason"] = f"职位序列「{seq}」不在门店服务/技师/管理序列,跳过"
|
||
return result
|
||
if config.text(star) in config.UNSUPPORTED_STARS:
|
||
result["reason"] = (f"星级「{config.text(star)}」不在标准表档位内"
|
||
"(只处理表里有的星级),跳过")
|
||
return result
|
||
result["account"] = account
|
||
result["account_id"] = accounts.get(account, {}).get("id", "")
|
||
|
||
if ignore:
|
||
result["action"] = ACTION_IGNORE
|
||
result["reason"] = ("入职当天借调(同日已有入职/再次入职待办),"
|
||
"该借调记录无需调薪,在 HR 中设为忽略")
|
||
return result
|
||
|
||
is_start_type = change_type in config.START_TYPES
|
||
if is_start_type:
|
||
if started:
|
||
result["action"] = ACTION_PENDING
|
||
result["reason"] = "入职类但已有起薪记录,需人工确认(可能二次入职)"
|
||
return result
|
||
result["action"] = ACTION_START
|
||
return result
|
||
|
||
if not started:
|
||
# 平台调薪弹窗同口径校验:没有起薪记录时提交只会返回「该员工没起薪,无需调薪」,
|
||
# 属不可处理的待办,记为跳过(不是异常),避免每条都堆成待人工。
|
||
result["action"] = ACTION_SKIP
|
||
result["reason"] = ("未起薪,无需调薪(平台校验口径「该员工没起薪,无需调薪」),跳过;"
|
||
"如该员工实际有停薪/复薪需求,请人工处理")
|
||
return result
|
||
|
||
wage_type = config.change_wage_type(change_type, change_name)
|
||
if not wage_type:
|
||
result["action"] = ACTION_PENDING
|
||
result["reason"] = f"异动类型「{change_name}」未映射到调薪类型,需人工确认"
|
||
return result
|
||
result["change_wage_type"] = wage_type
|
||
|
||
cur_account = _account_name(config.text(started.get("accountId")), accounts)
|
||
result["switch_account"] = bool(cur_account and cur_account != account)
|
||
result["action"] = ACTION_CHANGE
|
||
return result
|