|
|
|
@ -0,0 +1,552 @@
|
|
|
|
|
package com.weaver.sxjg.esb;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.weaver.ebuilder.common.exception.BusinessException;
|
|
|
|
|
import com.weaver.esb.api.rpc.EsbRpcRemoteInterface;
|
|
|
|
|
import com.weaver.sxjg.config.EbDbDataSourceConfig;
|
|
|
|
|
import com.weaver.sxjg.util.SxjgUtil;
|
|
|
|
|
import org.apache.commons.configuration.ConfigurationException;
|
|
|
|
|
import org.apache.commons.configuration.PropertiesConfiguration;
|
|
|
|
|
import org.apache.commons.httpclient.NameValuePair;
|
|
|
|
|
import org.apache.commons.httpclient.methods.PostMethod;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.jdbc.DataSourceBuilder;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author liuhao
|
|
|
|
|
* @use: 职位-新增,修改,发布,下线 接口对接智联招聘
|
|
|
|
|
* @date
|
|
|
|
|
*/
|
|
|
|
|
@Service("esbRpcPositionZhilian_sj")
|
|
|
|
|
public class EsbRpcPositionZhilian implements EsbRpcRemoteInterface {
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(EsbRpcPositionZhilian.class);
|
|
|
|
|
private String zlTokenUrl;
|
|
|
|
|
private String clientId;
|
|
|
|
|
private String clientSecret;
|
|
|
|
|
private String dicturl;
|
|
|
|
|
private String jobaddurl;
|
|
|
|
|
private String jobupdateurl;
|
|
|
|
|
private String jobpublishurl;
|
|
|
|
|
private String joboffline;
|
|
|
|
|
private String wslburl;
|
|
|
|
|
private String wslbxqurl;
|
|
|
|
|
@Autowired
|
|
|
|
|
public EbDbDataSourceConfig ebDbDataSourceConfig;
|
|
|
|
|
|
|
|
|
|
public EsbRpcPositionZhilian() {
|
|
|
|
|
PropertiesConfiguration p = null;
|
|
|
|
|
try {
|
|
|
|
|
p = new PropertiesConfiguration();
|
|
|
|
|
p.setEncoding("utf-8");
|
|
|
|
|
p.setFileName("config/sxjg.properties");
|
|
|
|
|
p.load();
|
|
|
|
|
this.setClientId(p.getString("sxjg.client_id"));
|
|
|
|
|
this.setClientSecret(p.getString("sxjg.client_secret"));
|
|
|
|
|
this.setZlTokenUrl(p.getString("sxjg.refreshtokenurl"));
|
|
|
|
|
this.setDicturl(p.getString("sxjg.dicturl"));
|
|
|
|
|
this.setJobaddurl(p.getString("sxjg.jobadd"));
|
|
|
|
|
this.setJobupdateurl(p.getString("sxjg.jobupdate"));
|
|
|
|
|
this.setJobpublishurl(p.getString("sxjg.jobpublish"));
|
|
|
|
|
this.setJoboffline(p.getString("sxjg.joboffline"));
|
|
|
|
|
this.setWslburl(p.getString("sxjg.wslburl"));
|
|
|
|
|
this.setWslbxqurl(p.getString("sxjg.wslbxqurl"));
|
|
|
|
|
}catch (ConfigurationException e) {
|
|
|
|
|
throw new BusinessException("获取sxjg.properties配置文件失败,", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> execute(Map<String, Object> params) {
|
|
|
|
|
String operate_flag = (String)params.get("operate_flag");
|
|
|
|
|
//1更新字典
|
|
|
|
|
if("1".equals(operate_flag)) {
|
|
|
|
|
log.error("定时更新字典启动:>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
updateRefreshDict(params,jdbcTemplate,"0000");
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}
|
|
|
|
|
//2 岗位新增,编辑,删除
|
|
|
|
|
else if("2".equals(operate_flag)) {
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
try {
|
|
|
|
|
jobAdd(params,jdbcTemplate);
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
return SxjgUtil.err(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//3 简历获取
|
|
|
|
|
else if("3".equals(operate_flag)) {
|
|
|
|
|
log.error("简历获取:>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
synchronJobTitle(jdbcTemplate);
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}
|
|
|
|
|
//4 岗位发布
|
|
|
|
|
else if("4".equals(operate_flag)) {
|
|
|
|
|
log.error("职位发布:>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
try{
|
|
|
|
|
publishjob(params,jdbcTemplate);
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return SxjgUtil.err(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//refresh token 定时
|
|
|
|
|
else if("5".equals(operate_flag)) {
|
|
|
|
|
log.error("定时刷新token启动:>>>>>>>>>>>>>>>>>>>>>>");
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
refreshToken(jdbcTemplate,"0000");
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}
|
|
|
|
|
else if("6".equals(operate_flag)) {//职位下线
|
|
|
|
|
JdbcTemplate jdbcTemplate = new JdbcTemplate(ebDbDataSourceConfig.dbDataSource());
|
|
|
|
|
try{
|
|
|
|
|
downjob(params,jdbcTemplate);
|
|
|
|
|
return SxjgUtil.ok();
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return SxjgUtil.err(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return SxjgUtil.err("配置不正确,请检查参数:operate_flag");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void synchronJobTitle(JdbcTemplate jdbcTemplate){
|
|
|
|
|
List<Map<String,Object>> rs = SxjgUtil.getZlTblist(jdbcTemplate);
|
|
|
|
|
if(CollectionUtil.isNotEmpty(rs)) {
|
|
|
|
|
for(Map<String,Object> m : rs) {
|
|
|
|
|
BigDecimal id = (BigDecimal)m.get("id");
|
|
|
|
|
String jobNumber = (String)m.get("zlzwid");
|
|
|
|
|
String subcompany = (String)m.get("sub_company");
|
|
|
|
|
String companyId = SxjgUtil.getZlbh(subcompany,jdbcTemplate);
|
|
|
|
|
String jobsyctime = (String)m.get("jobsyctime");//上一次更新时间
|
|
|
|
|
Date preTimesql = SxjgUtil.getDateByTimestr(jobsyctime,"yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String preTimejk = SxjgUtil.getTimeStrByDate(preTimesql,"yyyy/MM/dd HH:mm");
|
|
|
|
|
Date now = new Date();
|
|
|
|
|
String nowTimejk = SxjgUtil.getTimeStrByDate(now,"yyyy/MM/dd HH:mm");
|
|
|
|
|
String nowTimeSql = SxjgUtil.getTimeStrByDate(now,"yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
try{
|
|
|
|
|
getWsList(jobNumber,companyId,preTimejk,nowTimejk,jdbcTemplate);//一批量 有任何一次失败,则不更新时间
|
|
|
|
|
//更新该岗位的最后获取时间
|
|
|
|
|
SxjgUtil.updateLastTime(id,nowTimeSql,jdbcTemplate);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("根据jobNumber"+jobNumber+"获取网申列表失败,失败原因:"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void downjob(Map<String, Object> params, JdbcTemplate jdbcTemplate) throws Exception{
|
|
|
|
|
String id = (String)params.get("id");
|
|
|
|
|
log.error("职位下线,职位id:>>>>>>>>>>>>>>>>>>>>>>"+id);
|
|
|
|
|
String jobNumber = SxjgUtil.getJobNumber(id,jdbcTemplate);
|
|
|
|
|
if(jobNumber.length()==0) {
|
|
|
|
|
log.error("当前职位id:"+id+" 并未找到jobNumber,请先新增职位!");
|
|
|
|
|
throw new Exception("当前职位并未找到jobNumber!");
|
|
|
|
|
}
|
|
|
|
|
String orgCode = (String)params.get("orgcode");
|
|
|
|
|
String companyId = SxjgUtil.getZlbh(orgCode,jdbcTemplate);
|
|
|
|
|
long companyId1 = Long.parseLong(companyId);
|
|
|
|
|
if(companyId.length()==0){
|
|
|
|
|
throw new Exception("当前岗位所属组织并未配置,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("jobNumber",jobNumber);
|
|
|
|
|
jsonObject.put("companyId",companyId1);
|
|
|
|
|
String rs = SxjgUtil.doJsonPost(joboffline,this.getClientId(),jsonObject.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
if(SxjgUtil.isSuccess(rs)) {
|
|
|
|
|
JSONObject r1 =SxjgUtil.getInterfaceData(rs);
|
|
|
|
|
SxjgUtil.updateStatus(id,jdbcTemplate,"2");
|
|
|
|
|
}else {
|
|
|
|
|
throw new Exception("职位下线失败:"+rs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void publishjob(Map<String, Object> params, JdbcTemplate jdbcTemplate) throws Exception{
|
|
|
|
|
String id = (String)params.get("id");
|
|
|
|
|
String jobNumber = SxjgUtil.getJobNumber(id,jdbcTemplate);
|
|
|
|
|
if(jobNumber.length()==0) {
|
|
|
|
|
log.error("当前职位id:"+id+" 并未找到jobNumber,请先新增职位!");
|
|
|
|
|
throw new Exception("当前职位并未找到jobNumber!");
|
|
|
|
|
}
|
|
|
|
|
String orgCode = (String)params.get("orgcode");
|
|
|
|
|
String companyId = SxjgUtil.getZlbh(orgCode,jdbcTemplate);
|
|
|
|
|
long companyId1 = Long.parseLong(companyId);
|
|
|
|
|
if(companyId.length()==0){
|
|
|
|
|
throw new Exception("当前岗位所属组织并未配置,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
String qudao = (String)params.get("qudao");
|
|
|
|
|
if(!qudao.contains("智联招聘")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
jsonObject.put("jobNumber",jobNumber);
|
|
|
|
|
jsonObject.put("intoReview",0);
|
|
|
|
|
jsonObject.put("companyId",companyId1);
|
|
|
|
|
String rs = SxjgUtil.doJsonPost(jobpublishurl,this.getClientId(),jsonObject.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
if(SxjgUtil.isSuccess(rs)) {
|
|
|
|
|
SxjgUtil.updateStatus(id,jdbcTemplate,"1");
|
|
|
|
|
}else {
|
|
|
|
|
throw new Exception("职位发布失败:"+rs);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* isAdd 是新增 ,否更新
|
|
|
|
|
*/
|
|
|
|
|
private void jobAdd(Map<String, Object> params, JdbcTemplate jdbcTemplate) throws Exception {
|
|
|
|
|
boolean isAdd = true;
|
|
|
|
|
Map<String, Object> res = new HashMap<>();
|
|
|
|
|
String id = (String)params.get("id");
|
|
|
|
|
String qudao = (String)params.get("qudao");
|
|
|
|
|
if(!qudao.contains("智联招聘")){
|
|
|
|
|
throw new Exception("没有勾选智联招聘,当前数据不走同步接口");
|
|
|
|
|
}
|
|
|
|
|
String orgCode = (String)params.get("orgcode");
|
|
|
|
|
log.error("职位id:"+id);
|
|
|
|
|
log.error("职位所属公司code:"+orgCode);
|
|
|
|
|
String companyId = SxjgUtil.getZlbh(orgCode,jdbcTemplate);
|
|
|
|
|
long companyId1 = Long.parseLong(companyId);
|
|
|
|
|
if(companyId.length()==0){
|
|
|
|
|
throw new Exception("当前岗位所属组织并未配置,请联系管理员!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String jobNumber = SxjgUtil.getJobNumber(id,jdbcTemplate);
|
|
|
|
|
if(jobNumber.length()>0) {
|
|
|
|
|
isAdd = false;
|
|
|
|
|
}
|
|
|
|
|
log.error("职位所属公司code对应智联code:"+companyId);
|
|
|
|
|
log.error("发布渠道:"+qudao);
|
|
|
|
|
String jobNature = (String)params.get("jobNature");//职位属性
|
|
|
|
|
long jobType = SxjgUtil.getLastValuekey((String)params.get("jobType"),"/");
|
|
|
|
|
String jobTitle = (String)params.get("jobTitle");//职位名称
|
|
|
|
|
String city = (String)params.get("city");//工作城市
|
|
|
|
|
if(city.contains("市")) {
|
|
|
|
|
city= city.split("市")[0];
|
|
|
|
|
}
|
|
|
|
|
String jobAddress = (String)params.get("jobAddress");//工作地址
|
|
|
|
|
BigDecimal maxSalary = new BigDecimal((String)params.get("maxSalary"));//最大月薪
|
|
|
|
|
BigDecimal minSalary = new BigDecimal((String)params.get("minSalary"));//最小月薪
|
|
|
|
|
String quantity1 = (String)params.get("quantity");//招聘人数
|
|
|
|
|
int quantity = Double.valueOf(quantity1).intValue();
|
|
|
|
|
String education = (String)params.get("education");//最低学历
|
|
|
|
|
String workAge = (String)params.get("workAge");//工作年限
|
|
|
|
|
String jobDescription = (String)params.get("jobDescription");//职位描述
|
|
|
|
|
//转换智联
|
|
|
|
|
int jobNature1 = "实习".equals(jobNature) ? 4 : 2;
|
|
|
|
|
long cityId = SxjgUtil.getCityId(jdbcTemplate,city);
|
|
|
|
|
long maxSalary1 =maxSalary.multiply(new BigDecimal(1000)).longValue();
|
|
|
|
|
long minSalary1 =minSalary.multiply(new BigDecimal(1000)).longValue();
|
|
|
|
|
if((minSalary1*2) < maxSalary1) {
|
|
|
|
|
log.error("智联岗位新增:最大薪资不能超过最小薪资的2倍");
|
|
|
|
|
throw new Exception("智联岗位新增:最大薪资不能超过最小薪资的2倍");
|
|
|
|
|
}
|
|
|
|
|
if(jobDescription.length()<10) {
|
|
|
|
|
throw new Exception("智联岗位新增:岗位描述不能小于十个字");
|
|
|
|
|
}
|
|
|
|
|
if(minSalary1<1000l){
|
|
|
|
|
log.error("智联岗位新增:最低薪资不能小于1000");
|
|
|
|
|
throw new Exception("智联岗位新增:最低薪资不能小于1000");
|
|
|
|
|
}
|
|
|
|
|
int education1 = SxjgUtil.getEducode(education);
|
|
|
|
|
int workAge1 = SxjgUtil.getWordExpCode(workAge);
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
if(!isAdd){
|
|
|
|
|
jsonObject.put("jobNumber",jobNumber);
|
|
|
|
|
}
|
|
|
|
|
jsonObject.put("jobNature",jobNature1);
|
|
|
|
|
jsonObject.put("jobType",jobType);
|
|
|
|
|
jsonObject.put("jobTitle",jobTitle);
|
|
|
|
|
jsonObject.put("cityId",cityId);
|
|
|
|
|
jsonObject.put("jobAddress",jobAddress);
|
|
|
|
|
jsonObject.put("maxSalary",maxSalary1);
|
|
|
|
|
jsonObject.put("companyId",companyId1);
|
|
|
|
|
jsonObject.put("minSalary",minSalary1);
|
|
|
|
|
jsonObject.put("quantity",quantity);
|
|
|
|
|
jsonObject.put("education",education1);
|
|
|
|
|
jsonObject.put("workAge",workAge1);
|
|
|
|
|
jsonObject.put("jobDescription",jobDescription);
|
|
|
|
|
String url1 = isAdd ? this.getJobaddurl() : this.getJobupdateurl();
|
|
|
|
|
String rs = SxjgUtil.doJsonPost(url1,this.getClientId(),jsonObject.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
if(SxjgUtil.isSuccess(rs)) {
|
|
|
|
|
if(isAdd) {
|
|
|
|
|
JSONObject r1 =SxjgUtil.getInterfaceData(rs);
|
|
|
|
|
SxjgUtil.updateZhilianId(id,r1.getString("jobNumber"),jdbcTemplate);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
throw new Exception("职位新增接口异常!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新token,并且更新字典
|
|
|
|
|
*/
|
|
|
|
|
private Map<String, Object> updateRefreshDict(Map<String, Object> params,JdbcTemplate jdbcTemplate,String orgcode) {
|
|
|
|
|
Map<String, Object> res = new HashMap<>();
|
|
|
|
|
res.put("result",false);
|
|
|
|
|
res.put("description","");
|
|
|
|
|
JSONObject json1 = new JSONObject();
|
|
|
|
|
json1.put("dicType","REGIONS");
|
|
|
|
|
json1.put("page",1);
|
|
|
|
|
String s1 = SxjgUtil.doJsonPost(getDicturl(),getClientId(),json1.toJSONString(),jdbcTemplate,orgcode);
|
|
|
|
|
JSONObject rs1 = JSONObject.parseObject(s1);
|
|
|
|
|
JSONObject r11 = rs1.getJSONObject("data");
|
|
|
|
|
int total = r11.getInteger("total");
|
|
|
|
|
int yeshu = 0;
|
|
|
|
|
if(total%100 == 0) {
|
|
|
|
|
yeshu = total/100;
|
|
|
|
|
}else {
|
|
|
|
|
yeshu = total/100;
|
|
|
|
|
yeshu = yeshu+1;
|
|
|
|
|
}
|
|
|
|
|
for(int j = 1;j<=yeshu;j++) {
|
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
|
json.put("dicType","REGIONS");
|
|
|
|
|
json.put("page",j);
|
|
|
|
|
String s = SxjgUtil.doJsonPost(getDicturl(),getClientId(),json.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
JSONObject rs = JSONObject.parseObject(s);
|
|
|
|
|
JSONObject r1 = rs.getJSONObject("data");
|
|
|
|
|
JSONArray r2 = r1.getJSONArray("dataList");
|
|
|
|
|
for(int i = 0; i<r2.size();i++) {
|
|
|
|
|
JSONObject r3 = r2.getJSONObject(i);
|
|
|
|
|
String attribute = r3.getString("attribute");
|
|
|
|
|
String cnName = r3.getString("cnName");
|
|
|
|
|
String code = r3.getString("code");
|
|
|
|
|
String enName = r3.getString("enName");
|
|
|
|
|
String parentCode = r3.getString("parentCode");
|
|
|
|
|
String pyName = r3.getString("pyName");
|
|
|
|
|
String querysql = "select count(id) as sums from zhilian_zidian where code = "+code;
|
|
|
|
|
Map<String,Object> rs0 = jdbcTemplate.queryForMap(querysql);
|
|
|
|
|
long v = (Long) rs0.get("sums");
|
|
|
|
|
if(v==0l) {
|
|
|
|
|
String updateSql = "insert into zhilian_zidian(code,cnName,enName,parentCode,pyName," +
|
|
|
|
|
"attribute,type)values('"+code+"','"+cnName+"','"+enName+"','"+parentCode+"','"+pyName+"','"+attribute+"','"+"REGIONS"+"')";
|
|
|
|
|
jdbcTemplate.execute(updateSql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
res.put("result",true);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* use:获取网申列表,自行分页,从第一页开始,每次获取100条
|
|
|
|
|
*/
|
|
|
|
|
private void getWsList(String jobNumber,String companyId,String starttime,String endtime,JdbcTemplate jdbcTemplate) throws Exception{
|
|
|
|
|
JSONObject json1 = new JSONObject();
|
|
|
|
|
json1.put("page",1);
|
|
|
|
|
json1.put("pageSize",100);
|
|
|
|
|
json1.put("dateStart",starttime);
|
|
|
|
|
json1.put("dateEnd",endtime);
|
|
|
|
|
json1.put("jobNumber",jobNumber);
|
|
|
|
|
json1.put("companyId",companyId);
|
|
|
|
|
String s1 = SxjgUtil.doJsonPost(getWslburl(),getClientId(),json1.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
|
|
if(SxjgUtil.isSuccess(s1)) {
|
|
|
|
|
JSONObject data = SxjgUtil.getInterfaceData(s1);
|
|
|
|
|
int total = data.getInteger("total");
|
|
|
|
|
if(total == 0){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int yeshu = 0;
|
|
|
|
|
if(total%100 == 0) {
|
|
|
|
|
yeshu = total/100;
|
|
|
|
|
}else {
|
|
|
|
|
yeshu = total/100;
|
|
|
|
|
yeshu = yeshu+1;
|
|
|
|
|
}
|
|
|
|
|
//进入分页
|
|
|
|
|
for(int j = 1;j<=yeshu;j++) {
|
|
|
|
|
if(yeshu == 1) {
|
|
|
|
|
jsonArray = data.getJSONArray("dataList");
|
|
|
|
|
dealJsonArrayGetDetail(jsonArray,companyId,jobNumber,jdbcTemplate);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
json1 = new JSONObject();
|
|
|
|
|
json1.put("page",j);
|
|
|
|
|
json1.put("pageSize",100);
|
|
|
|
|
json1.put("dateStart",starttime);
|
|
|
|
|
json1.put("dateEnd",endtime);
|
|
|
|
|
json1.put("jobNumber",jobNumber);
|
|
|
|
|
json1.put("companyId",companyId);
|
|
|
|
|
s1 = SxjgUtil.doJsonPost(getWslburl(),getClientId(),json1.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
if(SxjgUtil.isSuccess(s1)) {
|
|
|
|
|
data = SxjgUtil.getInterfaceData(s1);
|
|
|
|
|
jsonArray = data.getJSONArray("dataList");
|
|
|
|
|
dealJsonArrayGetDetail(jsonArray,companyId,jobNumber,jdbcTemplate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
throw new Exception("获取网申列表详情失败,失败原因看日志!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取到时间段内的简历
|
|
|
|
|
*/
|
|
|
|
|
public void dealJsonArrayGetDetail(JSONArray jsonArray,String companyid,String jobNumber,JdbcTemplate jdbcTemplate) throws Exception{
|
|
|
|
|
for(int i = 0; i < jsonArray.size();i++) {
|
|
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
|
|
String jobResumeId = jsonObject.getString("jobResumeId");
|
|
|
|
|
JSONObject json1 = new JSONObject();
|
|
|
|
|
json1.put("jobResumeId",jobResumeId);
|
|
|
|
|
json1.put("companyId",companyid);
|
|
|
|
|
String s1 = SxjgUtil.doJsonPost(getWslbxqurl(),getClientId(),json1.toJSONString(),jdbcTemplate,"0000");
|
|
|
|
|
if(SxjgUtil.isSuccess(s1)) {
|
|
|
|
|
//处理批次
|
|
|
|
|
if(!SxjgUtil.existPc(jobResumeId,jobNumber,jdbcTemplate)) {
|
|
|
|
|
//成功录入批次后
|
|
|
|
|
// TODO: 2023/9/15 需要调用批次录用,成功后处理
|
|
|
|
|
String pcid = "";
|
|
|
|
|
//录入中间表,将已经成功同步的批次记录 记录批次编号,简历编号(智联)
|
|
|
|
|
SxjgUtil.insertSyn(jobResumeId,pcid,jobNumber,jdbcTemplate);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
throw new Exception("获取简历详情失败!具体明细请看日志");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
// public void test1(){
|
|
|
|
|
// DataSource db = DataSourceBuilder.create().driverClassName("com.mysql.cj.jdbc.Driver").username("ecology").password("uxJhLJn4%NpWxujAYyKsTpxP").url("jdbc:mysql://10.70.11.12:3306/ec_ebuilder_designer?characterEncoding=utf8&useSSL=false&autoReconnect=true&failOverReadOnly=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&allowMultiQueries=true").build();
|
|
|
|
|
// JdbcTemplate jdbcTemplate = new JdbcTemplate(db);
|
|
|
|
|
// refreshToken(jdbcTemplate,"0000");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private boolean refreshToken(JdbcTemplate jdbcTemplate,String orgcodes) {
|
|
|
|
|
boolean flag = false;
|
|
|
|
|
try {
|
|
|
|
|
String postURL;
|
|
|
|
|
PostMethod postMethod = null;
|
|
|
|
|
postMethod = new PostMethod(getZlTokenUrl());
|
|
|
|
|
System.out.println(getZlTokenUrl());
|
|
|
|
|
postMethod.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
|
|
|
|
|
NameValuePair[] data = {
|
|
|
|
|
new NameValuePair("client_id",getClientId()),
|
|
|
|
|
new NameValuePair("client_secret",getClientSecret()),
|
|
|
|
|
new NameValuePair("grant_type","refresh_token"),
|
|
|
|
|
new NameValuePair("refresh_token",SxjgUtil.getRt(jdbcTemplate,orgcodes))
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
postMethod.setRequestBody(data);
|
|
|
|
|
|
|
|
|
|
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
|
|
|
|
|
int response = httpClient.executeMethod(postMethod); // 执行POST方法
|
|
|
|
|
String result = postMethod.getResponseBodyAsString() ;
|
|
|
|
|
System.out.println(result);
|
|
|
|
|
// log.error("调用智联刷新token接口,返回值:>>>>>>>>>>>>>>>>>>>>>>"+result);
|
|
|
|
|
Map<String,String> rs1 = SxjgUtil.parseXmlToToken(result);
|
|
|
|
|
SxjgUtil.updateToken(rs1.get("at"),rs1.get("rt"),jdbcTemplate,orgcodes);
|
|
|
|
|
flag = true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
throw new RuntimeException(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取字典并更新数据库
|
|
|
|
|
*/
|
|
|
|
|
public boolean getDictUp() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public void setZlTokenUrl(String zlTokenUrl) {
|
|
|
|
|
this.zlTokenUrl = zlTokenUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getClientId() {
|
|
|
|
|
return clientId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setClientId(String clientId) {
|
|
|
|
|
this.clientId = clientId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getClientSecret() {
|
|
|
|
|
return clientSecret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setClientSecret(String clientSecret) {
|
|
|
|
|
this.clientSecret = clientSecret;
|
|
|
|
|
}
|
|
|
|
|
public String getZlTokenUrl() {
|
|
|
|
|
return zlTokenUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getDicturl() {
|
|
|
|
|
return dicturl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setDicturl(String dicturl) {
|
|
|
|
|
this.dicturl = dicturl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getJobaddurl() {
|
|
|
|
|
return jobaddurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setJobaddurl(String jobaddurl) {
|
|
|
|
|
this.jobaddurl = jobaddurl;
|
|
|
|
|
}
|
|
|
|
|
public String getJobupdateurl() {
|
|
|
|
|
return jobupdateurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setJobupdateurl(String jobupdateurl) {
|
|
|
|
|
this.jobupdateurl = jobupdateurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getJobpublishurl() {
|
|
|
|
|
return jobpublishurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setJobpublishurl(String jobpublishurl) {
|
|
|
|
|
this.jobpublishurl = jobpublishurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getJoboffline() {
|
|
|
|
|
return joboffline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setJoboffline(String joboffline) {
|
|
|
|
|
this.joboffline = joboffline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getWslburl() {
|
|
|
|
|
return wslburl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWslburl(String wslburl) {
|
|
|
|
|
this.wslburl = wslburl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getWslbxqurl() {
|
|
|
|
|
return wslbxqurl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWslbxqurl(String wslbxqurl) {
|
|
|
|
|
this.wslbxqurl = wslbxqurl;
|
|
|
|
|
}
|
|
|
|
|
}
|