1018 lines
40 KiB
Plaintext
1018 lines
40 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=utf-8" %>
|
||
<%@ page import="weaver.general.*,java.util.*,java.math.*" %>
|
||
<%@ page import="weaver.conn.RecordSet" %>
|
||
<%@ page import="java.net.HttpURLConnection" %>
|
||
<%@ page import="java.net.URLEncoder" %>
|
||
<%@ page import="java.net.URL" %>
|
||
<%@ page import="java.io.*" %>
|
||
<%@ page import="java.nio.charset.StandardCharsets" %>
|
||
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
||
<%@ page import="java.security.MessageDigest" %>
|
||
<%@ page import="java.security.NoSuchAlgorithmException" %>
|
||
<%@ page import="com.cloudstore.dev.api.bean.MessageType" %>
|
||
<%@ page import="com.cloudstore.dev.api.bean.MessageBean" %>
|
||
<%@ page import="com.cloudstore.dev.api.util.Util_Message" %>
|
||
<%@ page import="java.time.LocalDate" %>
|
||
<%@ page import="java.time.temporal.ChronoUnit" %>
|
||
<%@ page import="java.text.DecimalFormat" %>
|
||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||
<%@ page import="cn.hutool.http.HttpRequest" %>
|
||
<%@ page import="com.alibaba.fastjson.JSONArray" %>
|
||
<%@ page import="weaver.common.DateUtil" %>
|
||
<%@ page import="com.engine.hzzx.conn.DataUtil" %>
|
||
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
|
||
<%
|
||
int sum = 0;
|
||
|
||
|
||
try {
|
||
String accessToken = getToken();
|
||
// 获取近两天的数据
|
||
// String startTime = weaver.common.DateUtil.getYesterday() + "T00:00:00";
|
||
// String endTime = DateUtil.getCurrentDate() + "T23:59:59";
|
||
String startTime = "2025-01-01T00:00:00";
|
||
String endTime = "2025-08-14T23:59:59";
|
||
|
||
int yg_formModeId = DataUtil.getModeIdByTableName(EMPLOYEE_TABLE);
|
||
int sxs_formModeId = DataUtil.getModeIdByTableName(INTERNSHIP_TABLE);
|
||
int jyjl_formModeId = DataUtil.getModeIdByTableName(EDUCATION_TABLE);
|
||
int jtqk_formModeId = DataUtil.getModeIdByTableName(FAMILY_TABLE);
|
||
int gzjl_formModeId = DataUtil.getModeIdByTableName(WORK_EXPERIENCE_TABLE);
|
||
|
||
List<Map<String,Object>> list = getApplyidsAndJobid(startTime,endTime,accessToken);
|
||
for(Map<String,Object> map : list){
|
||
Map<String, String> yg_insertData = new HashMap<>();
|
||
Map<String, String> sxs_insertData = new HashMap<>();
|
||
|
||
String applyId = (String) map.get("applyidsList");
|
||
String jobGuid = (String) map.get("jobGuid");
|
||
Map<String,Object> jobInfo = getJobInfos(jobGuid,accessToken);
|
||
|
||
String uuid = UUID.randomUUID().toString();
|
||
|
||
yg_insertData.put("modeuuid", uuid);
|
||
yg_insertData.put("formmodeid", String.valueOf(yg_formModeId));
|
||
|
||
sxs_insertData.put("modeuuid", uuid);
|
||
sxs_insertData.put("formmodeid", String.valueOf(sxs_formModeId));
|
||
|
||
String maindata = httpGetRequestInfo(GET_RESUME_INFO_URL,applyId,accessToken);
|
||
JSONObject maindata_jsonObject = JSONObject.parseObject(maindata);
|
||
|
||
String data = maindata_jsonObject.get("data").toString();
|
||
JSONObject data_jsonObject = JSONObject.parseObject(data);
|
||
|
||
//姓名
|
||
String xm = "";
|
||
//性别
|
||
String xb = "";
|
||
//年龄
|
||
String nl = "";
|
||
//民族
|
||
String mz = "";
|
||
//移动电话
|
||
String yddh = "";
|
||
//身份证号码
|
||
String sfzhm = "";
|
||
//政治面貌 5-中共党员 6-中共预备党员 7-共青团员 8-民革会员 9-民盟盟员 10-民建会员 11-民进会员 12-农工党党员 13-致公党党员 14-九三学社社员 15-台盟盟员 16-无党派人士 17-群众 18-其他
|
||
String zzmm = "";
|
||
//籍贯
|
||
String jg = "";
|
||
//现通讯地址
|
||
String xtxdz = "";
|
||
//婚姻状况 0-未婚 1-已婚 2-丧偶 3-离异 4-其他
|
||
String hyzk = "";
|
||
//户口类别 0-本市农村 1-本市城镇 2-外市农村 3-外市城镇
|
||
String hklb = "";
|
||
//个人邮箱
|
||
String gryx = "";
|
||
//工作年限
|
||
String gznx = "";
|
||
//学校
|
||
String xx = "";
|
||
//专业
|
||
String zy = "";
|
||
//学历
|
||
String xl = "";
|
||
JSONArray itemArray = data_jsonObject.getJSONArray("personProfile");
|
||
for (int i = 0; i < itemArray.size(); i++) {
|
||
JSONObject dataObject = itemArray.getJSONObject(i);
|
||
|
||
String name = dataObject.get("name").toString();
|
||
String value = dataObject.get("value").toString();
|
||
String text = dataObject.get("text").toString();
|
||
//姓名
|
||
if("Name".equals(name)){
|
||
xm = text;
|
||
yg_insertData.put("xm",xm);
|
||
sxs_insertData.put("xm",xm);
|
||
}
|
||
//性别
|
||
if("Gender".equals(name)){
|
||
xb = value;
|
||
yg_insertData.put("xb",xb);
|
||
sxs_insertData.put("xb",xb);
|
||
}
|
||
//年龄
|
||
if("Birthday".equals(name)){
|
||
nl = calculateAge(text.replaceAll("/","-"));
|
||
yg_insertData.put("nl",nl);
|
||
}
|
||
//民族
|
||
if("Nation".equals(name)){
|
||
mz = getMzidByName(text);
|
||
yg_insertData.put("mz",mz);
|
||
sxs_insertData.put("mz",mz);
|
||
}
|
||
//移动电话
|
||
if("Mobile".equals(name)){
|
||
yddh = text;
|
||
yg_insertData.put("yddh",yddh);
|
||
sxs_insertData.put("yddh",yddh);
|
||
}
|
||
//身份证号码
|
||
if("CertificateNumber".equals(name)){
|
||
sfzhm = text;
|
||
yg_insertData.put("sfzhm",sfzhm);
|
||
sxs_insertData.put("sfzhm",sfzhm);
|
||
}
|
||
//政治面貌
|
||
if("Polity".equals(name)){
|
||
zzmm = getSelectidByName("9556",text);
|
||
yg_insertData.put("zzmm",zzmm);
|
||
sxs_insertData.put("zzmm",zzmm);
|
||
}
|
||
//籍贯
|
||
if("NativeArea".equals(name)){
|
||
jg = text;
|
||
yg_insertData.put("jg",jg);
|
||
sxs_insertData.put("jg",jg);
|
||
}
|
||
//现通讯地址
|
||
if("Address".equals(name)){
|
||
xtxdz = text;
|
||
yg_insertData.put("xtxdz",xtxdz);
|
||
sxs_insertData.put("xtxdz",xtxdz);
|
||
}
|
||
//婚姻状况 0-未婚 1-已婚 2-丧偶 3-离异 4-其他
|
||
if("WedState".equals(name)){
|
||
String vv = "";
|
||
if("2".equals(value)){
|
||
vv = "0";
|
||
}
|
||
if("5".equals(value)){
|
||
vv = "2";
|
||
}
|
||
hyzk = vv;
|
||
yg_insertData.put("hyzk", hyzk);
|
||
}
|
||
//户口类别
|
||
if("exthujixingzhi_613428_854390527".equals(name)){
|
||
hklb = getSelectidByName("11245",text);
|
||
yg_insertData.put("hklb", hklb);
|
||
}
|
||
//个人邮箱
|
||
if("Email".equals(name)){
|
||
gryx = text;
|
||
yg_insertData.put("gryx", gryx);
|
||
}
|
||
//工作年限
|
||
if("YearsOfWork".equals(name)){
|
||
gznx = text;
|
||
yg_insertData.put("gznx", gznx);
|
||
}
|
||
//学校
|
||
if("HighestSchool".equals(name)){
|
||
xx = text;
|
||
yg_insertData.put("xx", xx);
|
||
sxs_insertData.put("xx", xx);
|
||
}
|
||
//专业
|
||
if("HighestMajorName".equals(name)){
|
||
zy = text;
|
||
yg_insertData.put("zy", zy);
|
||
sxs_insertData.put("zy", zy);
|
||
}
|
||
//学历
|
||
if("EducationLevel".equals(name)){
|
||
// xl = getSelectidByName("9560",text);
|
||
if("大专".equals(text)){
|
||
xl = "0";
|
||
}else if("本科".equals(text)){
|
||
xl = "1";
|
||
}else if("硕士研究生".equals(text)){
|
||
xl = "2";
|
||
}else{
|
||
xl = "3";
|
||
}
|
||
yg_insertData.put("xl", xl);
|
||
sxs_insertData.put("xl", xl);
|
||
}
|
||
}
|
||
|
||
// 3-实习
|
||
String kind = jobInfo.get("kind").toString();
|
||
//岗位名称
|
||
String jobTitle = jobInfo.get("jobTitle").toString();
|
||
//岗位id
|
||
String jobId = getJobIdByName(jobTitle);
|
||
if(jobId != null && !"".equals(jobId)) {
|
||
yg_insertData.put("ypgw", jobId);
|
||
sxs_insertData.put("gw", jobId);
|
||
}
|
||
//北森部门id
|
||
String orgId = jobInfo.get("orgId").toString();
|
||
//部门编码
|
||
String deptcode = getDepartmentCode(Long.parseLong(orgId),accessToken);
|
||
//部门id
|
||
String deptId = getDepartmentId(deptcode);
|
||
if(deptId != null && !"".equals(deptId)) {
|
||
yg_insertData.put("ypbm", deptId);
|
||
sxs_insertData.put("szbm", deptId);
|
||
}
|
||
|
||
//实习生
|
||
if("3".equals(kind)){
|
||
DataUtil.buildModeInsertFields(sxs_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(sxs_insertData, INTERNSHIP_TABLE);
|
||
DataUtil.refreshRight(uuid, INTERNSHIP_TABLE, sxs_formModeId, OPERATE_ID);
|
||
}
|
||
//一般员工
|
||
else{
|
||
DataUtil.buildModeInsertFields(yg_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(yg_insertData, EMPLOYEE_TABLE);
|
||
DataUtil.refreshRight(uuid, EMPLOYEE_TABLE, yg_formModeId, OPERATE_ID);
|
||
}
|
||
|
||
rs.writeLog("========== insert into employee info success ================= ");
|
||
|
||
//入学时间
|
||
String rxsj = "";
|
||
//毕业时间
|
||
String bysj = "";
|
||
//毕业院校
|
||
String byyx = "";
|
||
//学习专业
|
||
String xxzy = "";
|
||
//教育经历
|
||
JSONArray jyjlArray = data_jsonObject.getJSONArray("education");
|
||
if(jyjlArray.size() > 0) {
|
||
for (int i = 0; i < jyjlArray.size(); i++) {
|
||
JSONArray dataArray = jyjlArray.getJSONArray(i);
|
||
Map<String, String> jyjl_insertData = new HashMap<>();
|
||
String uuid_jyjl = UUID.randomUUID().toString();
|
||
for (int j = 0; j < dataArray.size(); j++) {
|
||
JSONObject dataObject = dataArray.getJSONObject(j);
|
||
|
||
String name = dataObject.get("name").toString();
|
||
String value = dataObject.get("value").toString();
|
||
String text = dataObject.get("text").toString();
|
||
|
||
jyjl_insertData.put("modeuuid", uuid_jyjl);
|
||
jyjl_insertData.put("formmodeid", String.valueOf(jyjl_formModeId));
|
||
|
||
jyjl_insertData.put("yddh",yddh);
|
||
//入学时间
|
||
if("StartDate".equals(name)){
|
||
rxsj = text.replaceAll("/","-")+"-01";
|
||
jyjl_insertData.put("rxsj", rxsj);
|
||
}
|
||
//毕业时间
|
||
if("EndDate".equals(name)){
|
||
bysj = text.replaceAll("/","-")+"-01";
|
||
jyjl_insertData.put("bysj", bysj);
|
||
}
|
||
//毕业院校
|
||
if("SchoolName".equals(name)){
|
||
byyx = text;
|
||
jyjl_insertData.put("byyx", byyx);
|
||
}
|
||
//毕业院校
|
||
if("MajorName".equals(name)){
|
||
xxzy = text;
|
||
jyjl_insertData.put("xxzy", xxzy);
|
||
}
|
||
//学历
|
||
if("EducationLevel".equals(name)){
|
||
if("大专".equals(text)){
|
||
xl = "0";
|
||
}else if("本科".equals(text)){
|
||
xl = "1";
|
||
}else if("硕士研究生".equals(text)){
|
||
xl = "2";
|
||
}else{
|
||
xl = "3";
|
||
}
|
||
jyjl_insertData.put("xl1", xl);
|
||
}
|
||
}
|
||
rs.writeLog("========== jyjl_insertData ================= "+ jyjl_insertData);
|
||
|
||
DataUtil.buildModeInsertFields(jyjl_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(jyjl_insertData, EDUCATION_TABLE);
|
||
DataUtil.refreshRight(uuid_jyjl, EDUCATION_TABLE, jyjl_formModeId, OPERATE_ID);
|
||
rs.writeLog("========== insert into jyjl info success ================= ");
|
||
}
|
||
}
|
||
|
||
//家庭成员姓名
|
||
String jtcyxm = "";
|
||
//关系
|
||
String gx = "";
|
||
//工作单位
|
||
String gzdw = "";
|
||
//政治面貌
|
||
String zzmm1 = "";
|
||
//家庭情况
|
||
JSONArray jtqkArray = data_jsonObject.getJSONArray("family");
|
||
if(jtqkArray.size() > 0) {
|
||
for (int i = 0; i < jtqkArray.size(); i++) {
|
||
JSONArray dataArray = jtqkArray.getJSONArray(i);
|
||
Map<String, String> jtqk_insertData = new HashMap<>();
|
||
String uuid_jtqk = UUID.randomUUID().toString();
|
||
for (int j = 0; j < dataArray.size(); j++) {
|
||
JSONObject dataObject = dataArray.getJSONObject(j);
|
||
|
||
String name = dataObject.get("name").toString();
|
||
String value = dataObject.get("value").toString();
|
||
String text = dataObject.get("text").toString();
|
||
|
||
jtqk_insertData.put("modeuuid", uuid_jtqk);
|
||
jtqk_insertData.put("formmodeid", String.valueOf(jtqk_formModeId));
|
||
|
||
jtqk_insertData.put("yddh",yddh);
|
||
//家庭成员姓名
|
||
if("Name".equals(name)){
|
||
jtcyxm = text;
|
||
jtqk_insertData.put("jtcyxm", jtcyxm);
|
||
}
|
||
//关系
|
||
if("relation".equals(name)){
|
||
if("父子".equals(text)){
|
||
gx = "0";
|
||
}else if("母子".equals(text)){
|
||
gx = "1";
|
||
}else{
|
||
gx = "3";
|
||
}
|
||
jtqk_insertData.put("gx", gx);
|
||
}
|
||
//工作单位
|
||
if("CompanyName".equals(name)){
|
||
gzdw = text;
|
||
jtqk_insertData.put("gzdw", gzdw);
|
||
}
|
||
//政治面貌
|
||
if("PoliticalStatus".equals(name)){
|
||
zzmm1 = value;
|
||
jtqk_insertData.put("zzmm", zzmm1);
|
||
}
|
||
}
|
||
DataUtil.buildModeInsertFields(jtqk_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(jtqk_insertData, FAMILY_TABLE);
|
||
DataUtil.refreshRight(uuid_jtqk, FAMILY_TABLE, jtqk_formModeId, OPERATE_ID);
|
||
}
|
||
}
|
||
|
||
//起始时间
|
||
String qssj = "";
|
||
//终止时间
|
||
String zzsj = "";
|
||
//工作履历 0-实习经历 1-工作经历
|
||
String gzll = "";
|
||
//履历单位
|
||
String lldw = "";
|
||
//劳动关系所属单位
|
||
String ldgxszdw = "";
|
||
//工作经历
|
||
JSONArray gzjlArray = data_jsonObject.getJSONArray("workExperience");
|
||
if(gzjlArray.size() > 0) {
|
||
for (int i = 0; i < gzjlArray.size(); i++) {
|
||
JSONArray dataArray = gzjlArray.getJSONArray(i);
|
||
String uuid_gzjl = UUID.randomUUID().toString();
|
||
Map<String, String> gzjl_insertData = new HashMap<>();
|
||
for (int j = 0; j < dataArray.size(); j++) {
|
||
JSONObject dataObject = dataArray.getJSONObject(j);
|
||
|
||
String name = dataObject.get("name").toString();
|
||
String value = dataObject.get("value").toString();
|
||
String text = dataObject.get("text").toString();
|
||
|
||
gzjl_insertData.put("modeuuid", uuid_gzjl);
|
||
gzjl_insertData.put("formmodeid", String.valueOf(gzjl_formModeId));
|
||
|
||
gzjl_insertData.put("yddh",yddh);
|
||
gzjl_insertData.put("gzll", "1");
|
||
//单位名称
|
||
if("CompanyName".equals(name)){
|
||
lldw = text;
|
||
ldgxszdw = text;
|
||
gzjl_insertData.put("lldw", lldw);
|
||
gzjl_insertData.put("ldgxszdw", ldgxszdw);
|
||
}
|
||
//起始时间
|
||
if("StartDate".equals(name)){
|
||
qssj = text.replaceAll("/","-")+"-01";
|
||
gzjl_insertData.put("qssj", qssj);
|
||
}
|
||
//终止时间
|
||
if("EndDate".equals(name)){
|
||
zzsj = text.replaceAll("/","-")+"-01";
|
||
gzjl_insertData.put("zzsj", zzsj);
|
||
}
|
||
}
|
||
DataUtil.buildModeInsertFields(gzjl_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(gzjl_insertData, WORK_EXPERIENCE_TABLE);
|
||
DataUtil.refreshRight(uuid, WORK_EXPERIENCE_TABLE, gzjl_formModeId, OPERATE_ID);
|
||
}
|
||
}
|
||
|
||
//实习经历
|
||
JSONArray sxjlArray = data_jsonObject.getJSONArray("internship");
|
||
if(sxjlArray.size() > 0) {
|
||
for (int i = 0; i < sxjlArray.size(); i++) {
|
||
JSONArray dataArray = sxjlArray.getJSONArray(i);
|
||
String uuid_sxjl = UUID.randomUUID().toString();
|
||
Map<String, String> sxjl_insertData = new HashMap<>();
|
||
for (int j = 0; j < dataArray.size(); j++) {
|
||
JSONObject dataObject = dataArray.getJSONObject(j);
|
||
|
||
String name = dataObject.get("name").toString();
|
||
String value = dataObject.get("value").toString();
|
||
String text = dataObject.get("text").toString();
|
||
|
||
sxjl_insertData.put("modeuuid", uuid_sxjl);
|
||
sxjl_insertData.put("formmodeid", String.valueOf(gzjl_formModeId));
|
||
|
||
sxjl_insertData.put("yddh",yddh);
|
||
sxjl_insertData.put("gzll", "0");
|
||
//单位名称
|
||
if("CompanyName".equals(name)){
|
||
lldw = text;
|
||
ldgxszdw = text;
|
||
sxjl_insertData.put("lldw", lldw);
|
||
sxjl_insertData.put("ldgxszdw", ldgxszdw);
|
||
}
|
||
//起始时间
|
||
if("StartDate".equals(name)){
|
||
qssj = text.replaceAll("/","-")+"-01";
|
||
sxjl_insertData.put("qssj", qssj);
|
||
}
|
||
//终止时间
|
||
if("EndDate".equals(name)){
|
||
zzsj = text.replaceAll("/","-")+"-01";
|
||
sxjl_insertData.put("zzsj", zzsj);
|
||
}
|
||
}
|
||
DataUtil.buildModeInsertFields(sxjl_insertData, OPERATE_ID);
|
||
// 插入数据,刷新权限
|
||
DataUtil.insertData(sxjl_insertData, WORK_EXPERIENCE_TABLE);
|
||
DataUtil.refreshRight(uuid, WORK_EXPERIENCE_TABLE, gzjl_formModeId, OPERATE_ID);
|
||
}
|
||
}
|
||
|
||
String processId = getProcessIdByApplyid(applyId,accessToken);
|
||
|
||
Map<String,Object> mapp = GetProcessConfigById(GET_PROCESS_CONFIG_URL,processId,accessToken);
|
||
|
||
String phaseId = (String) mapp.get("phaseId");
|
||
String statusId = (String) mapp.get("statusId");
|
||
|
||
String resultcode = transferPhase(applyId,processId,phaseId,statusId,accessToken);
|
||
if("200".equals(resultcode)){
|
||
sum++;
|
||
}
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
|
||
%>
|
||
|
||
<%!
|
||
|
||
private static String TOKEN_URL = "https://openapi.italent.cn/token";
|
||
|
||
private static String APP_KEY = "EE7D602509E04A59AE5DEFF0841F6A1C";
|
||
|
||
private static String APP_SECRET = "F5229D9D83BF45DEBFA1EF8DAC13C0339D0074419CFE45FA8BAC2A0B9D170798";
|
||
// 获取所有申请ID
|
||
private static String GET_APPLYS_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Apply/GetApplysByPhaseStatusCode";
|
||
// 获取 岗位详情
|
||
private static String GET_JOB_INFO_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Job/GetJobListByIds";
|
||
// 获取 部门详情
|
||
private static String GET_DEPARTMENT_URL = "https://openapi.italent.cn/TenantBaseExternal/api/v5/Organization/GetByIds";
|
||
// 根据申请Id获取标准简历
|
||
private static String GET_RESUME_INFO_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Applicant/GetResumeByApplyId";
|
||
// 根据申请ID获取申请信息
|
||
private static String GET_APPLYLIST_BYAPPLYID_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Apply/GetApplyListByApplyId";
|
||
// 根据流程id获取流程及其包含阶段状态内容
|
||
private static String GET_PROCESS_CONFIG_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Setting/GetProcessConfigById";
|
||
// 转移阶段状态
|
||
private static String TRANSFER_PHASE_URL = "https://openapi.italent.cn/RecruitV6/api/v1/Apply/TransferPhase";
|
||
|
||
private static String EMPLOYEE_TABLE = "uf_ybygzqbssjtz";
|
||
|
||
private static String INTERNSHIP_TABLE = "uf_sxszqbssjtz";
|
||
|
||
//教育经历
|
||
private static String EDUCATION_TABLE = "uf_jxjl";
|
||
|
||
//家庭情况
|
||
private static String FAMILY_TABLE = "uf_jtqk";
|
||
|
||
//工作经历
|
||
private static String WORK_EXPERIENCE_TABLE = "uf_gzjj";
|
||
|
||
private static String OPERATE_ID = "1";
|
||
|
||
RecordSet rs = new RecordSet();
|
||
|
||
/**
|
||
* 根据 日期 计算年龄
|
||
* @param birthdate
|
||
* @return
|
||
*/
|
||
public String calculateAge(String birthdate) {
|
||
String result = "0";
|
||
try {
|
||
// 解析日期
|
||
LocalDate startDate = LocalDate.parse(birthdate);
|
||
LocalDate endDate = LocalDate.now();
|
||
// 计算工龄(月份)
|
||
long monthsBetween = ChronoUnit.MONTHS.between(startDate, endDate);
|
||
// 将月份转换为年并格式化为2位小数
|
||
double years = (double) monthsBetween / 12;
|
||
// DecimalFormat df = new DecimalFormat("0"); // 设置格式为2位小数
|
||
result = String.valueOf((int)years);
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 根据部门编码获取部门id
|
||
* @param departmentCode
|
||
* @return
|
||
*/
|
||
public String getDepartmentId(String departmentCode) {
|
||
String departmentId = "";
|
||
RecordSet rs = new RecordSet();
|
||
if (StringUtils.isBlank(departmentCode)) {
|
||
return departmentId;
|
||
}
|
||
rs.executeQuery("select id from hrmdepartment where departmentcode = ?", departmentCode);
|
||
if (rs.next()) {
|
||
departmentId = rs.getString("id");
|
||
}
|
||
return departmentId;
|
||
}
|
||
|
||
/**
|
||
* 根据岗位名称获取岗位id
|
||
* @param name
|
||
* @return
|
||
*/
|
||
public String getJobIdByName(String name) {
|
||
String jobtitleId = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select id from uf_gwgl where gwmc = ?", name);
|
||
if (rs.next()) {
|
||
jobtitleId = rs.getString("id");
|
||
}
|
||
return jobtitleId;
|
||
}
|
||
|
||
/**
|
||
* 根据民族名称获取民族id
|
||
* @param name
|
||
* @return
|
||
*/
|
||
public String getMzidByName(String name) {
|
||
String jobtitleId = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select id from uf_mz_ where mz = ?", name);
|
||
if (rs.next()) {
|
||
jobtitleId = rs.getString("id");
|
||
}
|
||
return jobtitleId;
|
||
}
|
||
|
||
/**
|
||
* 根据政治面貌名称获取下拉框id
|
||
* @param fieldid
|
||
* @param name
|
||
* @return
|
||
*/
|
||
public String getSelectidByName(String fieldid,String name) {
|
||
String jobtitleId = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select selectvalue from workflow_selectitem where 1=1 and fieldid=? and (cancel is null or cancel=0) and selectname = ?", fieldid, name);
|
||
if (rs.next()) {
|
||
jobtitleId = rs.getString("selectvalue");
|
||
}
|
||
return jobtitleId;
|
||
}
|
||
|
||
/**
|
||
* 获取 申请ID 和 岗位id
|
||
* @param startTime
|
||
* @param endTime
|
||
* @param accessToken
|
||
* @return
|
||
*/
|
||
public List<Map<String,Object>> getApplyidsAndJobid(String startTime, String endTime, String accessToken){
|
||
List<Map<String,Object>> list = new ArrayList<>();
|
||
JSONObject json = new JSONObject();
|
||
json.put("startTime", startTime);
|
||
json.put("endTime", endTime);
|
||
json.put("phaseCode", "S018");
|
||
json.put("statusCode", "U504");
|
||
// json.put("phaseCode", "S009");
|
||
// json.put("statusCode", "U007");
|
||
json.put("batchId", "");
|
||
json.put("processCode", "");
|
||
|
||
String response = HttpRequest.post(GET_APPLYS_URL)
|
||
.header("Authorization", "Bearer " + accessToken)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("GetByTimeWindow,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("getApplyids 接口调用失败");
|
||
}
|
||
String data = jsonObject.getString("data");
|
||
JSONObject dataJsonObject = JSONObject.parseObject(data);
|
||
JSONArray itemArray = dataJsonObject.getJSONArray("items");
|
||
if (itemArray == null || itemArray.size() == 0) {
|
||
rs.writeLog("getApplyids,无数据");
|
||
return new ArrayList<>();
|
||
}
|
||
for (int i = 0; i < itemArray.size(); i++) {
|
||
Map<String,Object> map = new HashMap<>();
|
||
|
||
JSONObject dataObject = itemArray.getJSONObject(i);
|
||
String applyId = dataObject.getString("applyId");
|
||
String jobLite = dataObject.getString("jobLite");
|
||
JSONObject jobJsonObject = JSONObject.parseObject(jobLite);
|
||
String jobGuid = jobJsonObject.getString("jobGuid");
|
||
|
||
map.put("applyidsList",applyId);
|
||
map.put("jobGuid",jobGuid);
|
||
|
||
list.add(map);
|
||
}
|
||
return list;
|
||
}
|
||
|
||
/**
|
||
* 发送 http get 请求,参数以原生字符串进行提交
|
||
* @param urll
|
||
* @param applyId
|
||
* @param token
|
||
* @return
|
||
*/
|
||
public String httpGetRequestInfo(String urll, String applyId, String token){
|
||
String result = "";
|
||
HttpURLConnection conn = null;
|
||
InputStream in=null;
|
||
BufferedReader reader=null;
|
||
int statusCode = 0;
|
||
try {
|
||
StringBuilder urlBuilder = new StringBuilder(urll);
|
||
urlBuilder.append("?");
|
||
urlBuilder.append("applyId").append("=").append(URLEncoder.encode(applyId, "UTF-8"));
|
||
|
||
System.out.println(" urlParameters : " + urlBuilder);
|
||
|
||
URL url = new URL(urlBuilder.toString());
|
||
conn = (HttpURLConnection) url.openConnection();
|
||
conn.setRequestMethod("GET");
|
||
conn.setRequestProperty("Authorization", "Bearer "+ token);
|
||
conn.setDoOutput(true);
|
||
conn.setDoInput(true);
|
||
conn.setUseCaches(false);
|
||
|
||
statusCode = conn.getResponseCode();
|
||
System.out.println(statusCode);
|
||
if (statusCode == 200) {
|
||
in = conn.getInputStream();
|
||
//通过InputStreamReader将字节流转换成字符串,在通过BufferedReader将字符流转换成自带缓冲流
|
||
reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||
StringBuilder sb = new StringBuilder();
|
||
String line = null;
|
||
//按行读取
|
||
while ((line = reader.readLine()) != null) {
|
||
sb.append(line);
|
||
}
|
||
result = sb.toString();
|
||
System.out.println(result);
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if (conn != null) {
|
||
conn.disconnect();
|
||
}
|
||
if (in != null) {
|
||
try {
|
||
in.close();
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
if (reader != null) {
|
||
try {
|
||
reader.close();
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 根据流程id获取流程及其包含阶段状态内容
|
||
* @param urll
|
||
* @param processId
|
||
* @param token
|
||
* @return
|
||
*/
|
||
public Map<String,Object> GetProcessConfigById(String urll, String processId, String token){
|
||
Map<String,Object> map = new HashMap<>();
|
||
String result = "";
|
||
HttpURLConnection conn = null;
|
||
InputStream in=null;
|
||
BufferedReader reader=null;
|
||
int statusCode = 0;
|
||
try {
|
||
StringBuilder urlBuilder = new StringBuilder(urll);
|
||
urlBuilder.append("?");
|
||
urlBuilder.append("processId").append("=").append(URLEncoder.encode(processId, "UTF-8"));
|
||
|
||
System.out.println(" urlParameters : " + urlBuilder);
|
||
|
||
URL url = new URL(urlBuilder.toString());
|
||
conn = (HttpURLConnection) url.openConnection();
|
||
conn.setRequestMethod("GET");
|
||
conn.setRequestProperty("Authorization", "Bearer "+ token);
|
||
conn.setDoOutput(true);
|
||
conn.setDoInput(true);
|
||
conn.setUseCaches(false);
|
||
|
||
statusCode = conn.getResponseCode();
|
||
System.out.println(statusCode);
|
||
if (statusCode == 200) {
|
||
in = conn.getInputStream();
|
||
//通过InputStreamReader将字节流转换成字符串,在通过BufferedReader将字符流转换成自带缓冲流
|
||
reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
|
||
StringBuilder sb = new StringBuilder();
|
||
String line = null;
|
||
//按行读取
|
||
while ((line = reader.readLine()) != null) {
|
||
sb.append(line);
|
||
}
|
||
result = sb.toString();
|
||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("getJobInfos 接口调用失败");
|
||
}
|
||
String data = jsonObject.getString("data");
|
||
JSONObject dataJsonObject = JSONObject.parseObject(data);
|
||
JSONArray phaseArray = dataJsonObject.getJSONArray("phaseList");
|
||
rs.writeLog("phaseArray,返参===" + phaseArray);
|
||
for (int i = 0; i < phaseArray.size(); i++) {
|
||
JSONObject dataObject = phaseArray.getJSONObject(i);
|
||
String phaseId = dataObject.getString("phaseId");
|
||
String phaseCode = dataObject.getString("phaseCode");
|
||
if("S018".equals(phaseCode)){
|
||
map.put("phaseId",phaseId);
|
||
JSONArray statusArray = dataObject.getJSONArray("statusList");
|
||
rs.writeLog("statusArray,返参===" + statusArray);
|
||
for (int j = 0; j < statusArray.size(); j++) {
|
||
JSONObject dataObjectt = statusArray.getJSONObject(j);
|
||
String statuscode = dataObjectt.getString("statusCode");
|
||
String statusId = dataObjectt.getString("statusId");
|
||
if("U505".equals(statuscode)){
|
||
map.put("statusId",statusId);
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}finally{
|
||
if (conn != null) {
|
||
conn.disconnect();
|
||
}
|
||
if (in != null) {
|
||
try {
|
||
in.close();
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
if (reader != null) {
|
||
try {
|
||
reader.close();
|
||
} catch (IOException e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
}
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 获取 申请ID 和 岗位id
|
||
* @param jobGuid
|
||
* @param accessToken
|
||
* @return
|
||
*/
|
||
public Map<String,Object> getJobInfos(String jobGuid, String accessToken){
|
||
Map<String,Object> map = new HashMap<>();
|
||
JSONObject json = new JSONObject();
|
||
json.put("jobIds", new String[]{jobGuid});
|
||
|
||
String response = HttpRequest.post(GET_JOB_INFO_URL)
|
||
.header("Authorization", "Bearer " + accessToken)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("getJobInfos,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("getJobInfos 接口调用失败");
|
||
}
|
||
JSONArray data = jsonObject.getJSONArray("data");
|
||
if (data.size() == 0) {
|
||
return new HashMap<>();
|
||
}
|
||
JSONObject dataObject = data.getJSONObject(0);
|
||
|
||
String jobTitle = dataObject.getString("jobTitle");
|
||
String jobCode = dataObject.getString("jobCode");
|
||
String orgId = dataObject.getString("orgId");
|
||
String kind = dataObject.getString("kind");
|
||
|
||
map.put("jobTitle",jobTitle);
|
||
map.put("jobCode",jobCode);
|
||
map.put("orgId",orgId);
|
||
// 3-实习
|
||
map.put("kind",kind);
|
||
|
||
return map;
|
||
}
|
||
|
||
/**
|
||
* 获取根据申请ID获取申请信息
|
||
* @param applyId
|
||
* @param accessToken
|
||
* @return
|
||
*/
|
||
public String getProcessIdByApplyid(String applyId, String accessToken){
|
||
String result = "";
|
||
JSONObject json = new JSONObject();
|
||
json.put("applyIds", new String[]{applyId});
|
||
|
||
String response = HttpRequest.post(GET_APPLYLIST_BYAPPLYID_URL)
|
||
.header("Authorization", "Bearer " + accessToken)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("getProcessIdByApplyid,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("getProcessIdByApplyid 接口调用失败");
|
||
}
|
||
JSONArray data = jsonObject.getJSONArray("data");
|
||
if (data.size() == 0) {
|
||
return "";
|
||
}
|
||
JSONObject dataObject = data.getJSONObject(0);
|
||
result = dataObject.getString("processId");
|
||
|
||
return result;
|
||
}
|
||
|
||
public String transferPhase(String applyId,String processId,String phaseId,String statusId,String accessToken){
|
||
String result = "";
|
||
JSONObject json = new JSONObject();
|
||
json.put("applyIds", new String[]{applyId});
|
||
json.put("processId", processId);
|
||
json.put("phaseId", phaseId);
|
||
json.put("statusId", statusId);
|
||
|
||
rs.writeLog("transferPhase,入参===" + json);
|
||
String response = HttpRequest.post(TRANSFER_PHASE_URL)
|
||
.header("Authorization", "Bearer " + accessToken)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("transferPhase,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("transferPhase 接口调用失败");
|
||
}
|
||
result = code;
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取部门信息
|
||
*
|
||
* @param oId
|
||
* @param accessToken
|
||
* @return
|
||
*/
|
||
private String getDepartmentCode(Long oId, String accessToken) {
|
||
String deptcode = "";
|
||
JSONObject json = new JSONObject();
|
||
json.put("oIds", new Long[]{oId});
|
||
rs.writeLog("getDepartmentCode,入参===" + json);
|
||
String response = HttpRequest.post(GET_DEPARTMENT_URL)
|
||
.header("Authorization", "Bearer " + accessToken)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("getDepartmentCode,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String code = jsonObject.getString("code");
|
||
if (!"200".equals(code)) {
|
||
throw new RuntimeException("getDepartmentCode接口调用失败");
|
||
}
|
||
JSONArray data = jsonObject.getJSONArray("data");
|
||
if (data.size() == 0) {
|
||
return null;
|
||
}
|
||
JSONObject dataObject = data.getJSONObject(0);
|
||
deptcode = dataObject.getString("code");
|
||
return deptcode;
|
||
|
||
}
|
||
|
||
/**
|
||
* 获取access_token
|
||
*
|
||
* @return
|
||
*/
|
||
private String getToken() {
|
||
JSONObject json = new JSONObject();
|
||
json.put("grant_type", "client_credentials");
|
||
json.put("app_key", APP_KEY);
|
||
json.put("app_secret", APP_SECRET);
|
||
rs.writeLog("获取token,入参===" + json);
|
||
String response = HttpRequest.post(TOKEN_URL)
|
||
.body(json.toString())
|
||
.contentType("application/json")
|
||
.execute()
|
||
.body();
|
||
rs.writeLog("获取token,返参===" + response);
|
||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||
|
||
String accessToken = jsonObject.getString("access_token");
|
||
if (StringUtils.isBlank(accessToken)) {
|
||
throw new RuntimeException("获取token失败");
|
||
}
|
||
return accessToken;
|
||
}
|
||
|
||
|
||
%>
|
||
|
||
<HEAD>
|
||
</HEAD>
|
||
<BODY>
|
||
|
||
<h1>Congratulation Mode 666666 !</h1>
|
||
|
||
<h1> sum <%=sum%> </h1>
|
||
|
||
</BODY>
|