refactor: 统一所有缓存/会话文件的存储路径
1. 重构会话管理模块,新增app.common.app_paths统一管理缓存路径,所有登录态与缓存统一迁移至%LOCALAPPDATA%\37duAutomation\.sessions 2. 更新所有涉及文件存储路径的代码,包括考勤、工资卡、社保、审批等模块 3. 新增银行字典缓存功能,统一管理银行编码映射 4. 添加雇主险业务模块,实现花名册筛选复制功能 5. 更新.gitignore,将所有.sessions目录纳入忽略列表 6. 删除影刀脚本旧的本地缓存文件 7. 优化加班审批校验逻辑,新增提前到岗型加班校验规则 8. 完善工资卡核对功能,补充开卡银行信息展示
This commit is contained in:
@@ -1,132 +1,121 @@
|
||||
加班api
|
||||
// ============================================================
|
||||
// 功能:从员工花名册筛选数据,复制到雇主险变更记录表(仅复制,不校验)
|
||||
// 适用:WPS 表格 (JS宏 / JSA)
|
||||
// 说明:自动根据当前日期生成目标文件名,无需手动选择
|
||||
// ============================================================
|
||||
|
||||
请求 URL
|
||||
function 筛选复制花名册() {
|
||||
// ============================================================
|
||||
// 第一步:配置常量
|
||||
// ============================================================
|
||||
const EMPLOYEE_FILE = "D:\\资料\\人资\\雇主险\\员工花名册.xlsx";
|
||||
const SOURCE_SHEET = "雇主险增减员导出模板";
|
||||
const TARGET_SHEET = "花名册导出-雇主险使用基础信息";
|
||||
const EXCLUDE_DEPT = ["金色湖畔事业部", "秒创传媒事业部", "水庄大鹅事业部"];
|
||||
|
||||
https://hr.37du.co/RedseaPlatform/kqController/getPageAjaxList.mc
|
||||
// ============================================================
|
||||
// 第二步:自动生成当天目标文件路径
|
||||
// ============================================================
|
||||
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"
|
||||
|
||||
请求方法
|
||||
var INSURANCE_FILE = "D:\\资料\\人资\\雇主险\\三十七度-雇主险变更记录-" + dateStr + ".xlsx";
|
||||
|
||||
POST
|
||||
STRU_TREE_CODE=cq37du&user_id=07b83185-6243-42bc-b79f-b81b4cffb471&sqlId=kq_overtime_detail_select&commonQuery=&commonQueryStr=&BPM_STATUS=&post_no=&postName=&source=&IS_SUBSIDY=&person_status=&staff_id=&staffNames=&post_type=1&processing_reason=&start_operat_time=&end_operat_time=&base_code=37008520&staff_name=&WORK_OVERTIME_TYPE=&start_time=2026-08-01&end_time=2026-08-31&start=0&sortType=desc&sortName=OPERATE_TIME&pageNo=1&pageSize=15
|
||||
{
|
||||
"attributeMap" : null,
|
||||
"count" : 2,
|
||||
"datas" : [ {
|
||||
"ORG_FULL_PATH" : "集团-网络技术组",
|
||||
"idCard" : "340621888883634",
|
||||
"base_code" : "37008520",
|
||||
"POST_ALIAS_NAME" : "3级软件工程师(Java)",
|
||||
"POST_ALIAS" : "3级软件工程师(Java)",
|
||||
"POST_ORG_NAME" : "3级软件工程师(Java)",
|
||||
"dept_one" : null,
|
||||
"dept_two" : null,
|
||||
"DEPT_ORG_ONE" : "网络信息部",
|
||||
"DEPT_ORG_TWO" : "网络技术组",
|
||||
"DEPT_ORG_THREE" : null,
|
||||
"DEPT_ORG_FOUR" : null,
|
||||
"DEPT_ORG_FIVE" : null,
|
||||
"STRU_TREE_CODE" : "cq37du-00013-00005-00002",
|
||||
"DEPT_ORG_NAME" : "网络技术组",
|
||||
"DEPT_STRU_ID" : "74fffc5a-e391-4d60-a4df-fe3c0dd73f64",
|
||||
"BELONG_UNIT_ORG_NAME" : "集团营建中心",
|
||||
"BELONG_UNIT_STRU_ID" : "b9cee736-cef2-11ee-b449-000c296f9469",
|
||||
"S_TIME" : null,
|
||||
"E_TIME" : null,
|
||||
"DETAIL_ID" : "bpmd415eae50d8f41258d7f8cce092b7a8b",
|
||||
"BUSINESS_KEY" : "bpmd415eae50d8f41258d7f8cce092b7a8b",
|
||||
"STAFF_ID" : "6026df21-7a9f-11ec-b449-000c296f9469",
|
||||
"STAFF_NAME" : "陈岗",
|
||||
"BPM_STATUS" : "002",
|
||||
"SOURCE" : "1",
|
||||
"ROOT_ID" : "cq37du",
|
||||
"START_TIME" : "2026-08-09 10:00:00",
|
||||
"END_TIME" : "2026-08-09 18:00:00",
|
||||
"OT_DATE" : "2026-08-09",
|
||||
"OT_LONG" : 0,
|
||||
"WORK_OVERTIME_TYPE" : "3",
|
||||
"FINAL_HOURS" : 0.0,
|
||||
"ot_hours" : 0.0,
|
||||
"NOTE" : "留宿退款功能",
|
||||
"PLAN_START_TIME" : "2026-08-09 10:00:00",
|
||||
"PLAN_END_TIME" : "2026-08-09 18:00:00",
|
||||
"ACTUAL_START_TIME" : "2026-08-09 10:00:00",
|
||||
"ACTUAL_END_TIME" : "2026-08-09 18:00:00",
|
||||
"OT_MIN_BEGIN_MINUTE" : "60",
|
||||
"OT_MIN_MINUTE" : "30",
|
||||
"OT_MIN_TYPE" : "1",
|
||||
"OT_SB_TYPE" : "2",
|
||||
"SB_DA_RANGE" : 360,
|
||||
"SB_TIME_MORE" : "1",
|
||||
"SB_TIME_LESS" : "2",
|
||||
"OT_XB_TYPE" : "2",
|
||||
"XB_DA_RANGE" : 360,
|
||||
"XB_TIME_MORE" : "2",
|
||||
"XB_TIME_LESS" : "1",
|
||||
"IS_SUBSIDY" : "1",
|
||||
"CEATE_USER" : "e79e9532-8a63-4421-a4f1-b96e8fd26d7c",
|
||||
"CEATE_USER_NAME" : "陈岗",
|
||||
"CREATE_TIME" : "2026-08-09 23:35:14",
|
||||
"OPERATOR" : "刘纤",
|
||||
"OPERATE_TIME" : "2026-08-10 16:20:19",
|
||||
"IN_USE" : "1",
|
||||
"CHAR_1" : null,
|
||||
"CHAR_2" : null,
|
||||
"NUM_1" : null,
|
||||
"NUM_2" : null,
|
||||
"plan_begin_date" : null,
|
||||
"plan_begin_other_name" : null,
|
||||
"plan_end_date" : null,
|
||||
"plan_end_other_name" : null,
|
||||
"begin_date" : null,
|
||||
"begin_other_name" : null,
|
||||
"end_date" : null,
|
||||
"end_other_name" : null,
|
||||
"if_other_name_open" : "0",
|
||||
"plan_begin_date_other_name" : null,
|
||||
"plan_end_date_other_name" : null,
|
||||
"begin_date_other_name" : null,
|
||||
"end_date_other_name" : null,
|
||||
"plan_ot_days" : 1.00,
|
||||
"ot_days" : 1.00,
|
||||
"sys_ot_days" : 1.00,
|
||||
"time_unit" : "1",
|
||||
"processing_reason" : null,
|
||||
"FINAL_START_TIME" : "2026-08-09 10:00:00",
|
||||
"FINAL_END_TIME" : "2026-08-09 18:00:00",
|
||||
"kqext_create_user_id" : null,
|
||||
"kqext_create_time" : null,
|
||||
"kqext_operator_id" : null,
|
||||
"kqext_operate_time" : null,
|
||||
"kqext_ext_delay_ot_hours" : null,
|
||||
"hrext_hsb_ext_speciality" : null,
|
||||
"hrext_ext_technician_code" : "",
|
||||
"hrext_ext_cal_person2" : null,
|
||||
"hrext_ext_call_phone2" : null,
|
||||
"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" : null,
|
||||
"hrext_ext_Have_worked" : "",
|
||||
"hrext_ext_family_join" : "",
|
||||
"hrext_ext_criminal_record" : "",
|
||||
"hrext_ext_infectious_disease" : "",
|
||||
"hrext_ext_References" : null,
|
||||
"hrext_ext_References_phone" : null,
|
||||
"hrext_ext_References_outside" : null,
|
||||
"hrext_ext_outside_References_phone" : null,
|
||||
"hrext_ext_is_dormitory" : "",
|
||||
"hrext_ext_process_approval_status" : "",
|
||||
"hrext_ext_trans_type" : "其他"
|
||||
},...]
|
||||
},
|
||||
"url" : null,
|
||||
"state" : "1",
|
||||
"meg" : "",
|
||||
"des" : "",
|
||||
"viewMapper" : null
|
||||
// 可选:检查文件是否存在(WPS JSA 中没有直接的文件存在判断函数,可尝试打开,但此处交给后续 Open 处理)
|
||||
|
||||
// ============================================================
|
||||
// 第三步:关闭刷新和事件,提升速度
|
||||
// ============================================================
|
||||
Application.ScreenUpdating = false;
|
||||
Application.EnableEvents = false;
|
||||
var startTime = new Date();
|
||||
|
||||
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;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user