refactor: 重构HRBP公共层与业务模块,整理废弃资源
1. 迁移并统一HR会话、配置、API等公共能力至hrbp/common层,实现ehr/oa模块复用 2. 删除captcha_debug调试用图片资源与旧session_manager文件 3. 重构考勤异常处理模块,补充分级逻辑与导出优化 4. 新增OA/HR多套API封装模块与配套文档 5. 移除旧通用接口规划文档,补充完整需求与开发文档
This commit is contained in:
@@ -1,121 +1,163 @@
|
||||
// ============================================================
|
||||
// 功能:从员工花名册筛选数据,复制到雇主险变更记录表(仅复制,不校验)
|
||||
// 适用:WPS 表格 (JS宏 / JSA)
|
||||
// 说明:自动根据当前日期生成目标文件名,无需手动选择
|
||||
// ============================================================
|
||||
员工排班
|
||||
|
||||
function 筛选复制花名册() {
|
||||
// ============================================================
|
||||
// 第一步:配置常量
|
||||
// ============================================================
|
||||
const EMPLOYEE_FILE = "D:\\资料\\人资\\雇主险\\员工花名册.xlsx";
|
||||
const SOURCE_SHEET = "雇主险增减员导出模板";
|
||||
const TARGET_SHEET = "花名册导出-雇主险使用基础信息";
|
||||
const EXCLUDE_DEPT = ["金色湖畔事业部", "秒创传媒事业部", "水庄大鹅事业部"];
|
||||
Request URL
|
||||
|
||||
// ============================================================
|
||||
// 第二步:自动生成当天目标文件路径
|
||||
// ============================================================
|
||||
var today = new Date();
|
||||
var year = today.getFullYear();
|
||||
var month = today.getMonth() + 1; // 月份从0开始,需+1
|
||||
var day = today.getDate();
|
||||
var dateStr = year + "." + month + "." + day; // 例如 "2026.8.12"
|
||||
https://hr.37du.co/RedseaPlatform/redmagicapi/rf_p_kq_count_SelectBanci/getExecutePageResult.mc
|
||||
|
||||
var INSURANCE_FILE = "D:\\资料\\人资\\雇主险\\三十七度-雇主险变更记录-" + dateStr + ".xlsx";
|
||||
Request Method
|
||||
|
||||
// 可选:检查文件是否存在(WPS JSA 中没有直接的文件存在判断函数,可尝试打开,但此处交给后续 Open 处理)
|
||||
POST
|
||||
|
||||
// ============================================================
|
||||
// 第三步:关闭刷新和事件,提升速度
|
||||
// ============================================================
|
||||
Application.ScreenUpdating = false;
|
||||
Application.EnableEvents = false;
|
||||
var startTime = new Date();
|
||||
treecode=cq37du&user_id=07b83185-6243-42bc-b79f-b81b4cffb471&sqlId=kq_count_SelectBanci&commonQuery=&commonQueryStr=&staff_ids=&person_status=1%2C4&post_no=&post_type=1&post_level=&identity=&showType=1&dateType=1&begin=2026-08-10&end=2026-08-16&bc_date=2026-08-14&base_code=37031376&staff_name=&start=0&sortType=&sortName=&pageNo=1&pageSize=15
|
||||
|
||||
try {
|
||||
// ============================================================
|
||||
// 第四步:打开文件
|
||||
// ============================================================
|
||||
var wbEmployee = Workbooks.Open(EMPLOYEE_FILE);
|
||||
var wbInsurance = Workbooks.Open(INSURANCE_FILE);
|
||||
var wsSource = wbEmployee.Sheets(SOURCE_SHEET);
|
||||
var wsTarget = wbInsurance.Sheets(TARGET_SHEET);
|
||||
|
||||
// ============================================================
|
||||
// 第五步:读取源数据(从第3行开始,跳过表头)
|
||||
// ============================================================
|
||||
var lastRow = wsSource.Cells(wsSource.Rows.Count, 2).End(-4162).Row;
|
||||
if (lastRow < 3) {
|
||||
alert("源表没有数据!");
|
||||
wbEmployee.Close(false);
|
||||
wbInsurance.Close(false);
|
||||
return;
|
||||
{
|
||||
"attributeMap": null,
|
||||
"count": 1,
|
||||
"datas": [
|
||||
{
|
||||
"staff_id": "70023bb2-a362-438c-ba46-2f165c502351",
|
||||
"work_day": "2026-08-10",
|
||||
"paiban_type": "-2",
|
||||
"priority": "0",
|
||||
"team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"sb_type": 0,
|
||||
"xb_type": 0,
|
||||
"begin_time": "09:00",
|
||||
"end_time": "18:00",
|
||||
"yq_total_min": 480,
|
||||
"change_value_day": 1.0,
|
||||
"remark": "",
|
||||
"team_name": "集团本部职能",
|
||||
"STAFF_ID": "70023bb2-a362-438c-ba46-2f165c502351",
|
||||
"STAFF_NAME": "郑荣斌",
|
||||
"base_code": "37031376",
|
||||
"join_date": "2025-10-15",
|
||||
"leaveOffice_date": null,
|
||||
"Regular_Time": "2026-01-15",
|
||||
"person_status": "1",
|
||||
"staff_status": "1",
|
||||
"identity": "1",
|
||||
"idCard": "500242********3177",
|
||||
"STRU_ID": "bfaf2462-a96f-11f0-a0a5-000c296f9469",
|
||||
"dept_one": null,
|
||||
"dept_two": null,
|
||||
"POST_LEVEL_ID": "8fdd4d7d-648d-11ec-b526-822ff8ed5b28",
|
||||
"POST_LEVEL_NAME": "总监",
|
||||
"DEPT_ORG_ONE": null,
|
||||
"DEPT_ORG_TWO": null,
|
||||
"DEPT_ORG_THREE": null,
|
||||
"DEPT_ORG_FOUR": null,
|
||||
"DEPT_ORG_FIVE": null,
|
||||
"POST_ALIAS": "财务总监",
|
||||
"POST_ORG_NAME": "财务总监",
|
||||
"BELONG_UNIT_STRU_ID": "e451622b-8be5-11f1-a7d9-000c296f9469",
|
||||
"BELONG_UNIT_ORG_NAME": "财务管理部",
|
||||
"DEPT_STRU_ID": "e451622b-8be5-11f1-a7d9-000c296f9469",
|
||||
"DEPT_ORG_NAME": "财务管理部",
|
||||
"POST_NO": "231",
|
||||
"POST_ALIAS_NAME": "财务总监",
|
||||
"ORG_FULL_PATH": "集团-财务管理部",
|
||||
"hrext_hsb_ext_speciality": null,
|
||||
"hrext_ext_technician_code": null,
|
||||
"hrext_ext_cal_person2": "",
|
||||
"hrext_ext_call_phone2": "",
|
||||
"hrext_ext_star_level": "正式",
|
||||
"hrext_ext_rehiring_reason_type": "",
|
||||
"hrext_ext_staff_type": "职能高层管理",
|
||||
"hrext_ext_insurance_type": "社会保险",
|
||||
"hrext_ext_recruit_way": "BOSS直聘",
|
||||
"hrext_ext_call_relationship2": "",
|
||||
"hrext_ext_is_CRBT_open": "",
|
||||
"hrext_ext_dept_principal": "",
|
||||
"hrext_ext_yb_pay_year": "",
|
||||
"hrext_ext_Have_worked": "",
|
||||
"hrext_ext_family_join": "否",
|
||||
"hrext_ext_criminal_record": "否",
|
||||
"hrext_ext_infectious_disease": "否",
|
||||
"hrext_ext_References": "",
|
||||
"hrext_ext_References_phone": "",
|
||||
"hrext_ext_References_outside": "",
|
||||
"hrext_ext_outside_References_phone": "",
|
||||
"hrext_ext_is_dormitory": "否",
|
||||
"hrext_ext_process_approval_status": "",
|
||||
"hrext_ext_trans_type": "其他",
|
||||
"bc_name": "职能正班A",
|
||||
"2026-08-10_bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"2026-08-10_bc_name": "职能正班A",
|
||||
"2026-08-10_bc_time": "09:00 ~ 18:00",
|
||||
"2026-08-10_paiban_type": "-2",
|
||||
"2026-08-10_remark": "",
|
||||
"2026-08-10_team_name": "集团本部职能",
|
||||
"2026-08-10_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-10_sb_type": 0,
|
||||
"2026-08-10_xb_type": 0,
|
||||
"2026-08-11_bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"2026-08-11_bc_name": "职能正班A",
|
||||
"2026-08-11_bc_time": "09:00 ~ 18:00",
|
||||
"2026-08-11_paiban_type": "-2",
|
||||
"2026-08-11_remark": "",
|
||||
"2026-08-11_team_name": "集团本部职能",
|
||||
"2026-08-11_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-11_sb_type": 0,
|
||||
"2026-08-11_xb_type": 0,
|
||||
"2026-08-12_bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"2026-08-12_bc_name": "职能正班A",
|
||||
"2026-08-12_bc_time": "09:00 ~ 18:00",
|
||||
"2026-08-12_paiban_type": "-2",
|
||||
"2026-08-12_remark": "",
|
||||
"2026-08-12_team_name": "集团本部职能",
|
||||
"2026-08-12_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-12_sb_type": 0,
|
||||
"2026-08-12_xb_type": 0,
|
||||
"2026-08-13_bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"2026-08-13_bc_name": "职能正班A",
|
||||
"2026-08-13_bc_time": "09:00 ~ 18:00",
|
||||
"2026-08-13_paiban_type": "-2",
|
||||
"2026-08-13_remark": "",
|
||||
"2026-08-13_team_name": "集团本部职能",
|
||||
"2026-08-13_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-13_sb_type": 0,
|
||||
"2026-08-13_xb_type": 0,
|
||||
"2026-08-14_bc_id": "de1daf426e7f4fa6916f3012434e8973",
|
||||
"2026-08-14_bc_name": "职能正班A",
|
||||
"2026-08-14_bc_time": "09:00 ~ 18:00",
|
||||
"2026-08-14_paiban_type": "-2",
|
||||
"2026-08-14_remark": "",
|
||||
"2026-08-14_team_name": "集团本部职能",
|
||||
"2026-08-14_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-14_sb_type": 0,
|
||||
"2026-08-14_xb_type": 0,
|
||||
"2026-08-15_bc_id": "4",
|
||||
"2026-08-15_bc_name": "休息",
|
||||
"2026-08-15_bc_time": "",
|
||||
"2026-08-15_paiban_type": "0",
|
||||
"2026-08-15_remark": "",
|
||||
"2026-08-15_team_name": "集团本部职能",
|
||||
"2026-08-15_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-15_sb_type": "",
|
||||
"2026-08-15_xb_type": "",
|
||||
"2026-08-16_bc_id": "4",
|
||||
"2026-08-16_bc_name": "休息",
|
||||
"2026-08-16_bc_time": "",
|
||||
"2026-08-16_paiban_type": "0",
|
||||
"2026-08-16_remark": "",
|
||||
"2026-08-16_team_name": "集团本部职能",
|
||||
"2026-08-16_team_id": "355945ef0e894881a21980b79b7dfbf1",
|
||||
"2026-08-16_sb_type": "",
|
||||
"2026-08-16_xb_type": "",
|
||||
"total_hours": 40.0,
|
||||
"total_day": 5
|
||||
}
|
||||
var dataRange = wsSource.Range("B3:O" + lastRow);
|
||||
var dataArray = dataRange.Value2;
|
||||
|
||||
// ============================================================
|
||||
// 第六步:过滤数据
|
||||
// ============================================================
|
||||
var resultArray = [];
|
||||
for (var i = 0; i < dataArray.length; i++) {
|
||||
var row = dataArray[i];
|
||||
var dept = row[0]; // B列
|
||||
var region = row[1]; // C列
|
||||
var excludeDept = false;
|
||||
for (var j = 0; j < EXCLUDE_DEPT.length; j++) {
|
||||
if (dept === EXCLUDE_DEPT[j]) { excludeDept = true; break; }
|
||||
}
|
||||
if (!excludeDept && region !== "虚拟大区") {
|
||||
resultArray.push(row);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultArray.length === 0) {
|
||||
alert("筛选后没有数据!");
|
||||
wbEmployee.Close(false);
|
||||
wbInsurance.Close(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 第七步:清空目标区域(B5:O 至最后非空行)
|
||||
// ============================================================
|
||||
var targetLastRow = wsTarget.Cells(wsTarget.Rows.Count, 2).End(-4162).Row;
|
||||
if (targetLastRow >= 5) {
|
||||
wsTarget.Range("B5:O" + targetLastRow).ClearContents();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 第八步:写入数据
|
||||
// ============================================================
|
||||
var writeRange = wsTarget.Range(
|
||||
wsTarget.Cells(5, 2),
|
||||
wsTarget.Cells(5 + resultArray.length - 1, 15)
|
||||
);
|
||||
writeRange.Value2 = resultArray;
|
||||
|
||||
// ============================================================
|
||||
// 第九步:保存并关闭
|
||||
// ============================================================
|
||||
wbInsurance.Save();
|
||||
wbEmployee.Close(false);
|
||||
wbInsurance.Close(false);
|
||||
|
||||
var elapsed = (new Date() - startTime) / 1000;
|
||||
Application.ScreenUpdating = true;
|
||||
Application.EnableEvents = true;
|
||||
alert("复制完成!\n共复制 " + resultArray.length + " 行数据\n耗时 " + elapsed.toFixed(2) + " 秒");
|
||||
|
||||
} catch (e) {
|
||||
Application.ScreenUpdating = true;
|
||||
Application.EnableEvents = true;
|
||||
// 如果文件不存在,Workbooks.Open 会抛出错误,捕获并提示
|
||||
if (e.message.indexOf("找不到") !== -1 || e.message.indexOf("不存在") !== -1) {
|
||||
alert("错误:未找到今日的目标文件(" + INSURANCE_FILE + "),请确认文件是否存在。");
|
||||
} else {
|
||||
alert("复制出错:" + e.message);
|
||||
}
|
||||
}
|
||||
],
|
||||
"pageSize": 15,
|
||||
"start": 0,
|
||||
"pageNo": 1,
|
||||
"pageCount": 1,
|
||||
"allDatas": null,
|
||||
"url": null,
|
||||
"state": "1",
|
||||
"meg": "",
|
||||
"des": "",
|
||||
"viewMapper": null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user