feat: 新增社保参保核对工具链,补全依赖并清理废弃文件
- 新增社保参保/停保状态核对核心逻辑,支持调用HR接口校验工号参保记录 - 新增滑块验证码改进版登录工具,支持缓存会话免重复登录 - 新增HR通用API封装模块 - 新增员工异动名单清洗、导出、核对全流程功能 - 新增依赖库xlrd、openpyxl、opencv等 - 删除旧的钉钉消息推送文档、测试用Excel、aa.md脚本文件 - 优化员工异动导出流程,自动完成去重和参保核对
This commit is contained in:
@@ -1,150 +1,123 @@
|
||||
<script type="text/javascript">
|
||||
var exportDialogObj = {exportUrl: "\/sys\/search\/search.do?method=exportResult&fdModelName=com.landray.kmss.km.review.model.KmReviewMain&searchId=1751adb6bd21bf5967d425c4c37b1596&canClose=false&isNew=true&j_aside=false&j_rIframe=true&j_iframe=true&j_timestamp=1786087301147", exportNum: "1263"};
|
||||
seajs.use( [ 'lui/jquery', 'lui/dialog' ], function($, dialog) {
|
||||
showExportDialog = function() {
|
||||
var selectedData = getSelectIndexs();
|
||||
var hasSelected = selectedData.length > 0 ? true : false;
|
||||
var url = '/sys/search/search_result_export.jsp?fdModelName=com.landray.kmss.km.review.model.KmReviewMain&searchId=1751adb6bd21bf5967d425c4c37b1596&hasSelected=' + hasSelected;
|
||||
dialog.iframe(url, '请选择需要导出的字段',
|
||||
function (value) {
|
||||
exportCallbak(value);
|
||||
},
|
||||
{width:460,height:500,params:{exportDialogObj:exportDialogObj}}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
exportCallbak = function(returnValue) {
|
||||
if(returnValue==null || returnValue==undefined){
|
||||
return;
|
||||
}
|
||||
var selectedData = getSelectIndexs();
|
||||
document.getElementsByName("fdNum")[0].value = 1263;
|
||||
document.getElementsByName("fdNumStart")[0].value = returnValue["fdNumStart"];
|
||||
document.getElementsByName("fdNumEnd")[0].value = returnValue["fdNumEnd"];
|
||||
document.getElementsByName("fdKeepRtfStyle")[0].checked = returnValue["fdKeepRtfStyle"];
|
||||
document.getElementsByName("fdColumns")[0].value = returnValue["fdColumns"];
|
||||
document.getElementsByName("checkIdValues")[0].value = selectedData.join("|");
|
||||
dialog.confirm('导出数据需要稍等片刻,期间请不要关闭窗口,不要多次重复执行导出操作,是否确认导出?',function(value){
|
||||
if(value == true) {
|
||||
if('com.landray.kmss.km.review.model.KmReviewMain' == 'com.landray.kmss.km.review.model.KmReviewMain'){
|
||||
var flag = false;
|
||||
var param = {fdModelName: "com.landray.kmss.km.review.model.KmReviewMain",
|
||||
searchId:'1751adb6bd21bf5967d425c4c37b1596',
|
||||
fdNum:document.getElementsByName("fdNum")[0].value,
|
||||
fdNumStart:document.getElementsByName("fdNumStart")[0].value,
|
||||
fdNumEnd:document.getElementsByName("fdNumEnd")[0].value,
|
||||
fdKeepRtfStyle:document.getElementsByName("fdKeepRtfStyle")[0].value,
|
||||
fdColumns:document.getElementsByName("fdColumns")[0].value,
|
||||
checkIdValues:document.getElementsByName("checkIdValues")[0].value
|
||||
};
|
||||
var url = '/sys/search/search.do?method=getSubTableTotal';
|
||||
$.ajax({
|
||||
url: url,
|
||||
type:"POST",
|
||||
dataType:"json",
|
||||
data: $.param(param, true),
|
||||
async:false,//同步请求
|
||||
success: function(json){
|
||||
if(json && json.count && json.count > 5000){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if(flag){
|
||||
dialog.alert('导出的数据中明细表行数量大于5000,为了避免服务器宕机,请修改导出的数据在5000以内。');
|
||||
return;
|
||||
}
|
||||
var url = '/sys/search/search.do?method=isRequestAllowed';
|
||||
var flag = false;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type:"POST",
|
||||
dataType:"json",
|
||||
async:false,//同步请求
|
||||
success: function(json){
|
||||
if(json && json.isAllowed){
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
if(!flag){
|
||||
dialog.alert('您当前导出操作次数过于频繁,请稍后再操作!');
|
||||
return;
|
||||
}
|
||||
}
|
||||
exportForm.action = exportDialogObj.exportUrl;
|
||||
exportForm.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getSelectIndexs = function() {
|
||||
var selectedData = [];
|
||||
var $table = $("#List_ViewTable");
|
||||
$table.find("[name='List_Selected']:checkbox").each(function(){
|
||||
if (this.checked){
|
||||
selectedData.push(this.value);
|
||||
}
|
||||
});
|
||||
return selectedData;
|
||||
}
|
||||
|
||||
hid = function(obj) {
|
||||
if(obj.checked)
|
||||
obj.parentNode.parentNode.style.display= "none ";
|
||||
}
|
||||
});
|
||||
|
||||
window.onload = function() {
|
||||
/* #127699 数据导出中,数据选择后,有部分数据显示未被选择中状态-开始 */
|
||||
$("#List_ViewTable>tbody>tr>td").mouseenter(function () {
|
||||
var href = $(this).parent("tr").attr("kmss_href");
|
||||
$(this).parent("tr").attr("same", "true");
|
||||
$(this).parent("tr").siblings().each(function () {
|
||||
if ($(this).attr("kmss_href") == href) {
|
||||
$(this).attr("same", "true");
|
||||
}
|
||||
})
|
||||
});
|
||||
import requests
|
||||
import csv
|
||||
import os
|
||||
|
||||
$("#List_ViewTable>tbody>tr>td").mouseleave(function () {
|
||||
var href = $(this).parent("tr").attr("kmss_href");
|
||||
$(this).parent("tr").attr("same", "false");
|
||||
$(this).parent("tr").siblings().each(function () {
|
||||
if ($(this).attr("kmss_href") == href) {
|
||||
$(this).attr("same", "false");
|
||||
}
|
||||
})
|
||||
});
|
||||
/* #127699 数据导出中,数据选择后,有部分数据显示未被选择中状态-结束 */
|
||||
};
|
||||
$(function() {
|
||||
// 监听页面的点击事件
|
||||
Com_AddEventListener(document, "click", function () {
|
||||
var eventObj = Com_GetEventObject();
|
||||
var eleObj = eventObj.srcElement || eventObj.target;
|
||||
var tagName = eleObj.tagName;
|
||||
if (tagName.toLowerCase() === 'a') {
|
||||
seajs.use(['lui/dialog'], function(dialog) {
|
||||
// 开启loading
|
||||
window.search_load = dialog.loading();
|
||||
});
|
||||
}
|
||||
});
|
||||
//监听回车,分页输入显示条数回车
|
||||
Com_AddEventListener(document, "keydown", function () {
|
||||
var eventObj = Com_GetEventObject();
|
||||
if(eventObj.keyCode==13) {
|
||||
var eleObj = eventObj.srcElement || eventObj.target;
|
||||
var tagName = eleObj.tagName;
|
||||
if (tagName.toLowerCase() === 'input') {
|
||||
seajs.use(['lui/dialog'], function (dialog) {
|
||||
// 开启loading
|
||||
window.search_load = dialog.loading();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
# 你的 Cookie 字符串(从浏览器复制完整)
|
||||
|
||||
COOKIE_STR = "你的完整Cookie"
|
||||
|
||||
# 基础参数模板(和之前一样)
|
||||
|
||||
BASE_PARAMS = {
|
||||
"start": "0",
|
||||
"pageNo": "1",
|
||||
"pageSize": "15",
|
||||
"USER_ID": "07b83185-6243-42bc-b79f-b81b4cffb471",
|
||||
"STRU_ID": "596bae33-50e9-11ec-b526-822ff8ed5b28",
|
||||
"STRU_TREE_CODE": "cq37du",
|
||||
"queryTempPersonType": "queryForList",
|
||||
"belongUnitStruId": "f1a6c12a-cef4-11ee-b449-000c296f9469",
|
||||
"fastMode": "0",
|
||||
"rootId": "cq37du",
|
||||
"_noTrans_": "noTrans",
|
||||
"defineColumnType": "5",
|
||||
"PERSON_STATUS": "",
|
||||
"SI_STATE": "98",
|
||||
"staff_names": "",
|
||||
"base_codes": "", # 这个会被动态替换
|
||||
"includeSubUnit": "1",
|
||||
"postStruId": "1",
|
||||
"regist_property": "",
|
||||
"identity": "",
|
||||
"idcards": "",
|
||||
"if_sb": "",
|
||||
"payOrgId": "",
|
||||
"payUnitId": "",
|
||||
"siName": "",
|
||||
"belongUnitId": "",
|
||||
"belongUnitName": "",
|
||||
"DEPT_NAME": "",
|
||||
"inputDeptName": "",
|
||||
"selectType": "1",
|
||||
"operator": "",
|
||||
"joinDate_begin": "", "joinDate_end": "",
|
||||
"leaveDate_begin": "", "leaveDate_end": "",
|
||||
"siBeginDate_begin": "", "siBeginDate_end": "",
|
||||
"siEndDate_begin": "", "siEndDate_end": "",
|
||||
}
|
||||
|
||||
HEADERS = {
|
||||
"Cookie": COOKIE_STR,
|
||||
"User-Agent": "Mozilla/5.0",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
}
|
||||
|
||||
def query_batch(codes_batch):
|
||||
"""查询一批工号(≤15个),返回响应 JSON"""
|
||||
params = BASE_PARAMS.copy()
|
||||
params["base_codes"] = ",".join(codes_batch)
|
||||
resp = requests.post(
|
||||
"https://hr.37du.co/RedseaPlatform/getPageAjax/si_main_SelectByTreeCode/CoreRequest.mc",
|
||||
data=params,
|
||||
headers=HEADERS,
|
||||
timeout=15
|
||||
)
|
||||
resp.raise_for_status() # 如果不是200会抛出异常
|
||||
return resp.json()
|
||||
|
||||
def extract_found_codes(response_json):
|
||||
"""从返回的JSON里提取所有出现的工号(base_Code)"""
|
||||
datas = response_json.get("datas", [])
|
||||
return [item["base_Code"] for item in datas if "base_Code" in item]
|
||||
|
||||
def check_batch(codes_batch):
|
||||
"""比较查询结果与输入工号,返回找到的、未找到的列表"""
|
||||
try:
|
||||
data = query_batch(codes_batch)
|
||||
found = extract_found_codes(data)
|
||||
missing = [c for c in codes_batch if c not in found]
|
||||
return found, missing, data
|
||||
except Exception as e:
|
||||
print(f"请求失败:{e}")
|
||||
return [], codes_batch, None
|
||||
|
||||
# ---------- 使用示例 ----------
|
||||
|
||||
# 假设你有一个大的工号列表
|
||||
|
||||
all_codes = [
|
||||
"37028192", "37030557", "37035022", "其他工号..."
|
||||
]
|
||||
|
||||
# 将大列表按15个一组拆分
|
||||
|
||||
batch_size = 15
|
||||
batches = [all_codes[i:i+batch_size] for i in range(0, len(all_codes), batch_size)]
|
||||
|
||||
all_found = []
|
||||
all_missing = []
|
||||
output_rows = [] # 用于存所有有数据的完整行,方便后续导出
|
||||
|
||||
for batch in batches:
|
||||
found, missing, resp_json = check_batch(batch)
|
||||
all_found.extend(found)
|
||||
all_missing.extend(missing)
|
||||
|
||||
# 如果找到数据,可以把这一批的完整行记录下来
|
||||
if resp_json and resp_json.get("datas"):
|
||||
output_rows.extend(resp_json["datas"])
|
||||
print(f"查询 {batch} → 找到 {found},未找到 {missing}")
|
||||
|
||||
print("\n=== 总结 ===")
|
||||
print(f"总计找到 {len(all_found)} 个工号:{all_found}")
|
||||
print(f"未找到 {len(all_missing)} 个工号:{all_missing}")
|
||||
|
||||
# 把有数据的记录保存为CSV(字段已全量输出)
|
||||
|
||||
if output_rows:
|
||||
keys = output_rows[0].keys()
|
||||
with open("found_si_data.csv", "w", newline="", encoding="utf-8-sig") as f:
|
||||
writer = csv.DictWriter(f, fieldnames=keys)
|
||||
writer.writeheader()
|
||||
writer.writerows(output_rows)
|
||||
print(f"有数据的记录已保存到 found_si_data.csv,共 {len(output_rows)} 条")
|
||||
|
||||
Reference in New Issue
Block a user