332 lines
12 KiB
Plaintext
332 lines
12 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
|
<%@page import="weaver.general.Util"%>
|
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
|
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
|
<%@ page import="java.util.*" %>
|
|
<%@ page import="weaver.conn.RecordSet" %>
|
|
<%@ page import="org.apache.http.client.methods.CloseableHttpResponse" %>
|
|
<%@ page import="org.apache.http.impl.client.CloseableHttpClient" %>
|
|
<%@ page import="org.apache.http.impl.client.HttpClients" %>
|
|
<%@ page import="org.apache.http.client.methods.HttpPost" %>
|
|
<%@ page import="org.apache.http.entity.StringEntity" %>
|
|
<%@ page import="org.apache.http.HttpEntity" %>
|
|
<%@ page import="org.apache.http.util.EntityUtils" %>
|
|
<%@ page import="java.io.IOException" %>
|
|
<%@ page import="weaver.hrm.company.DepartmentComInfo" %>
|
|
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
|
|
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
|
|
<jsp:useBean id="rs1" class="weaver.conn.RecordSet" scope="page" />
|
|
<jsp:useBean id="rst" class="weaver.conn.RecordSet" scope="page" />
|
|
<%
|
|
int add_sum = 0;
|
|
String add_message = "";
|
|
int leave_sum = 0;
|
|
String leave_message = "";
|
|
|
|
String codes = "";
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
String sql = "select a.*,b.createdate,b.createtime,b.lastoperatedate,b.lastoperatetime from formtable_main_72 a,workflow_requestbase b where a.requestid=b.requestid and b.currentnodetype=3";
|
|
rs.executeQuery(sql);
|
|
while(rs.next()){
|
|
//姓名
|
|
String userid = Util.null2String(rs.getString("xm"));
|
|
list.add(userid);
|
|
|
|
// 离职原因
|
|
String lzyyid = Util.null2String(rs.getString("lzyy"));
|
|
String lzyyname = getLzyyname(lzyyid);
|
|
|
|
// 离职类型 下拉框 0 - 主动 1 - 被动
|
|
int lzlxid = Util.getIntValue(rs.getString("lzlx"));
|
|
int lzlx = -1;
|
|
if(lzlxid==0){
|
|
lzlx = 2;
|
|
}else{
|
|
lzlx = 1;
|
|
}
|
|
|
|
// 最后离职日期
|
|
String tyzhgzr = Util.null2String(rs.getString("tyzhgzr"));
|
|
|
|
String createdate = Util.null2String(rs.getString("createdate"));
|
|
String createtime = Util.null2String(rs.getString("createtime"));
|
|
String lastoperatedate = Util.null2String(rs.getString("lastoperatedate"));
|
|
String lastoperatetime = Util.null2String(rs.getString("lastoperatetime"));
|
|
String lasttime = lastoperatetime.substring(0,5);
|
|
|
|
//离职时间
|
|
String leavetime = tyzhgzr+" "+lasttime;
|
|
|
|
|
|
String key = rs.getPropValue("hrm_zhongkong","key");
|
|
String url = rs.getPropValue("hrm_zhongkong","add_update_user_url");
|
|
url = url + "?key=" + key;
|
|
String leaveurl = rs.getPropValue("hrm_zhongkong","leave_user_url");
|
|
leaveurl = leaveurl + "?key=" + key;
|
|
Map<String,String> headers = new HashMap<>();
|
|
JSONArray jsonArray = new JSONArray();
|
|
JSONObject json_main = new JSONObject();
|
|
JSONObject json_main_leave = new JSONObject();
|
|
|
|
rs1.executeQuery("select * from hrmresource where status=5 and id=?",userid);
|
|
rs1.next();
|
|
String workcode = Util.null2String(rs1.getString("workcode"));
|
|
String lastname = Util.null2String(rs1.getString("lastname"));
|
|
String departmentid = Util.null2String(rs1.getString("departmentid"));
|
|
String mobile = Util.null2String(rs1.getString("mobile"));
|
|
String sex = Util.null2String(rs1.getString("sex"));
|
|
String certificatenum = Util.null2String(rs1.getString("certificatenum"));
|
|
String birthday = Util.null2String(rs1.getString("birthday"));
|
|
String companystartdate = Util.null2String(rs1.getString("companystartdate"));
|
|
|
|
String pincode = "";
|
|
String cuscode = getCusIdByUserid(userid);
|
|
if(cuscode != null && !"".equals(cuscode)){
|
|
pincode = cuscode;
|
|
}else{
|
|
pincode = workcode;
|
|
}
|
|
|
|
codes += pincode+ ",";
|
|
|
|
String deptcode = "";
|
|
String sup_Deptcode = getDeptCuscode(departmentid);
|
|
if(sup_Deptcode != null && !"".equals(sup_Deptcode)){
|
|
deptcode = sup_Deptcode;
|
|
}else{
|
|
deptcode = new DepartmentComInfo().getDepartmentCode(departmentid);
|
|
}
|
|
|
|
// 新增人员的 入参
|
|
json_main.put("pin",pincode);
|
|
json_main.put("name",lastname);
|
|
json_main.put("deptnumber",deptcode);
|
|
json_main.put("mobile",mobile);
|
|
json_main.put("gender","0".equals(sex)?"M":"F");
|
|
json_main.put("identitycard",certificatenum);
|
|
json_main.put("birthday",birthday);
|
|
json_main.put("hiredday",companystartdate);
|
|
|
|
jsonArray.add(json_main);
|
|
rs.writeLog("========================== 新增或修改人员,同步至中控考勤机 ======================================");
|
|
rs.writeLog(url+" ========= "+jsonArray.toString());
|
|
|
|
|
|
// 人员离职的入参
|
|
json_main_leave.put("pin",pincode);
|
|
json_main_leave.put("leavedate",leavetime);
|
|
json_main_leave.put("leavetype",lzlx);
|
|
json_main_leave.put("reason",lzyyname);
|
|
|
|
int result = -1;
|
|
String msg = "";
|
|
int result1 = -1;
|
|
String msg1 = "";
|
|
|
|
// String content = httpPost(url,headers,jsonArray.toString(),"utf-8");
|
|
// if (content != null && !"".equals(content)) {
|
|
// JSONObject json = JSONObject.parseObject(content);
|
|
// rs.writeLog("============= httpPost pushInfo json =================== " + json);
|
|
// int resultt = Integer.parseInt(json.getString("ret"));
|
|
// if(resultt == 0){
|
|
// result = 0;
|
|
// }else{
|
|
// result = 1;
|
|
// }
|
|
// msg = Util.null2String(json.getString("msg"));
|
|
// }
|
|
|
|
// if(result == 0){
|
|
// add_sum++;
|
|
// add_message += lastname +" ====== add user result ========== "+ msg+", ";
|
|
|
|
String contentt = httpPost(leaveurl,headers,json_main_leave.toString(),"utf-8");
|
|
if (contentt != null && !"".equals(contentt)) {
|
|
JSONObject json = JSONObject.parseObject(contentt);
|
|
rs.writeLog("============= httpPost pushInfo json =================== " + json);
|
|
int resultt = Integer.parseInt(json.getString("ret"));
|
|
if(resultt == 0){
|
|
result1 = 0;
|
|
}else{
|
|
result1 = 1;
|
|
}
|
|
msg1 = Util.null2String(json.getString("msg"));
|
|
}
|
|
if(result1 == 0) {
|
|
leave_sum++;
|
|
leave_message += lastname + " ====== leave user result ========== " + msg1 + ", ";
|
|
}
|
|
// }
|
|
}
|
|
|
|
int len = list.size();
|
|
String userids = "";
|
|
String usernames = "";
|
|
for(String userid : list){
|
|
String username = new ResourceComInfo().getLastname(userid);
|
|
usernames += username +",";
|
|
userids += userid +",";
|
|
}
|
|
|
|
if(userids.endsWith(",")){
|
|
userids = userids.substring(0,userids.length()-1);
|
|
}
|
|
if(usernames.endsWith(",")){
|
|
usernames = usernames.substring(0,usernames.length()-1);
|
|
}
|
|
if(codes.endsWith(",")){
|
|
codes = codes.substring(0,codes.length()-1);
|
|
}
|
|
|
|
|
|
|
|
%>
|
|
|
|
<%!
|
|
|
|
/**
|
|
* post 请求 json格式
|
|
* @param url
|
|
* @param headers
|
|
* @param stringJson
|
|
* @param encode
|
|
* @return
|
|
*/
|
|
public static String httpPost(String url, Map<String,String> headers, String stringJson, String encode){
|
|
int result = 0;
|
|
if(encode == null){
|
|
encode = "utf-8";
|
|
}
|
|
RecordSet rs = new RecordSet();
|
|
String content = "";
|
|
CloseableHttpResponse httpResponse = null;
|
|
CloseableHttpClient closeableHttpClient = null;
|
|
try {
|
|
closeableHttpClient = HttpClients.createDefault();
|
|
HttpPost httpost = new HttpPost(url);
|
|
//设置header
|
|
httpost.setHeader("Content-type", "application/json");
|
|
if (headers != null && headers.size() > 0) {
|
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
|
httpost.setHeader(entry.getKey(),entry.getValue());
|
|
}
|
|
}
|
|
//组织请求参数
|
|
StringEntity stringEntity = new StringEntity(stringJson, encode);
|
|
httpost.setEntity(stringEntity);
|
|
//响应信息
|
|
httpResponse = closeableHttpClient.execute(httpost);
|
|
if(httpResponse != null) {
|
|
HttpEntity entity = httpResponse.getEntity();
|
|
content = EntityUtils.toString(entity, encode);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
rs.writeLog(e);
|
|
}finally{
|
|
try {
|
|
httpResponse.close();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
try { //关闭连接、释放资源
|
|
closeableHttpClient.close();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return content;
|
|
}
|
|
|
|
/**
|
|
* 获取 部门中控系统id
|
|
* @param deptid
|
|
* @return
|
|
*/
|
|
public static String getDeptCuscode(String deptid){
|
|
RecordSet rs = new RecordSet();
|
|
String code = "";
|
|
rs.executeQuery("select zkxtid from hrmdepartmentdefined where deptid = ?",deptid);
|
|
if(rs.next()){
|
|
code = Util.null2String(rs.getString("zkxtid"));
|
|
}
|
|
return code;
|
|
}
|
|
|
|
/**
|
|
* 获取 分部 中控系统id
|
|
* @param subcomid
|
|
* @return
|
|
*/
|
|
public static String getSubcomCuscode(String subcomid){
|
|
RecordSet rs = new RecordSet();
|
|
String code = "";
|
|
rs.executeQuery("select zkid from hrmsubcompanydefined where subcomid = ?",subcomid);
|
|
if(rs.next()){
|
|
code = Util.null2String(rs.getString("zkid"));
|
|
}
|
|
return code;
|
|
}
|
|
|
|
/**
|
|
* 根据 人员id 获取 自定义 考勤卡号,也就是 中控考勤机那边的 人员编号 pin
|
|
* @param userid
|
|
* @return
|
|
*/
|
|
public static String getCusIdByUserid(String userid){
|
|
String result = "";
|
|
RecordSet rs = new RecordSet();
|
|
String kq_fieldid = rs.getPropValue("hrm_zhongkong","kq_fieldid");
|
|
rs.executeQuery("select "+ kq_fieldid +" from cus_fielddata where scope = 'HrmCustomFieldByInfoType' and scopeid = -1 and id = ?",userid);
|
|
if(rs.next()){
|
|
result = Util.null2String(rs.getString(kq_fieldid));
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 获取 离职原因 名称
|
|
* @param lzyyid
|
|
* @return
|
|
*/
|
|
public static String getLzyyname(String lzyyid){
|
|
String result = "";
|
|
RecordSet rs = new RecordSet();
|
|
String lzyy_fieldid = rs.getPropValue("hrm_zhongkong","lzyy_fieldid");
|
|
if (lzyyid != null && !"".equals(lzyyid)) {
|
|
rs.executeQuery("select selectname from workflow_selectitem where cancel=0 and fieldid = ? and selectvalue=?", lzyy_fieldid, lzyyid);
|
|
if (rs.next()) {
|
|
result = Util.null2String(rs.getString("selectname"));
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
%>
|
|
|
|
|
|
<HEAD>
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<h1>Congratulation Mode 666666 !</h1>
|
|
|
|
<h1> 新增的人数 <%=add_sum%> </h1>
|
|
|
|
<h1> 新增的人是: <%=add_message%></h1>
|
|
|
|
<h1> 离职的 人数 <%=leave_sum%> </h1>
|
|
|
|
<h1> 离职的人是: <%=leave_message%></h1>
|
|
|
|
<h1> 新增的人数 <%=len%> </h1>
|
|
|
|
<h1> 离职的人数id <%=userids%> </h1>
|
|
|
|
<h1> 离职的人数的工号 <%=codes%> </h1>
|
|
|
|
<h1> 新增的人是这些 <%=usernames%> </h1>
|
|
|
|
</BODY> |