|
|
|
@ -0,0 +1,266 @@
|
|
|
|
|
package com.weaver.sxjg.assess.esb;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.weaver.common.base.entity.result.WeaResult;
|
|
|
|
|
import com.weaver.ebuilder.common.exception.BusinessException;
|
|
|
|
|
import com.weaver.ebuilder.form.client.entity.obj.Obj;
|
|
|
|
|
import com.weaver.ebuilder.form.client.utils.UserUtils;
|
|
|
|
|
import com.weaver.esb.api.rpc.EsbServerlessRpcRemoteInterface;
|
|
|
|
|
import com.weaver.eteams.file.client.file.FileObj;
|
|
|
|
|
import com.weaver.eteams.file.client.param.RemoteUploadParam;
|
|
|
|
|
import com.weaver.file.ud.api.FileUploadService;
|
|
|
|
|
import com.weaver.sxjg.assess.config.EbDbDataSourceConfig;
|
|
|
|
|
import com.weaver.sxjg.assess.util.SxjgUtil;
|
|
|
|
|
import com.weaver.teams.security.UserAgentUtils;
|
|
|
|
|
import org.apache.commons.configuration.ConfigurationException;
|
|
|
|
|
import org.apache.commons.configuration.PropertiesConfiguration;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.net.URLConnection;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @use:发送测评通知
|
|
|
|
|
* @date 2023年10月16日
|
|
|
|
|
* @author 刘浩
|
|
|
|
|
*/
|
|
|
|
|
@Service("esbRpcAssessManage_sj")
|
|
|
|
|
public class SendAssessNotice implements EsbServerlessRpcRemoteInterface {
|
|
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(SendAssessNotice.class);
|
|
|
|
|
|
|
|
|
|
private JdbcTemplate jdbcTemplate = new JdbcTemplate(EbDbDataSourceConfig.dbDataSource());
|
|
|
|
|
private int companyId;
|
|
|
|
|
|
|
|
|
|
private String secret;
|
|
|
|
|
|
|
|
|
|
private String assessNoticeUrl;
|
|
|
|
|
|
|
|
|
|
private String tenantKey;
|
|
|
|
|
private String managerid;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
FileUploadService fileUploadService;
|
|
|
|
|
|
|
|
|
|
private String assessResultUrl;
|
|
|
|
|
|
|
|
|
|
public SendAssessNotice() {
|
|
|
|
|
PropertiesConfiguration p = null;
|
|
|
|
|
try {
|
|
|
|
|
p = new PropertiesConfiguration();
|
|
|
|
|
p.setEncoding("utf-8");
|
|
|
|
|
p.setFileName("config/assessManage.properties");
|
|
|
|
|
p.load();
|
|
|
|
|
this.setCompanyId(p.getString("sxjg.companyid"));
|
|
|
|
|
this.setSecret(p.getString("sxjg.secret"));
|
|
|
|
|
this.setAssessNoticeUrl(p.getString("sxjg.answerurl"));
|
|
|
|
|
this.setAssessResultUrl(p.getString("sxjg.answerresult"));
|
|
|
|
|
this.setManagerid(p.getString("managerid"));
|
|
|
|
|
this.setTenantKey(p.getString("tenantKey"));
|
|
|
|
|
}catch (ConfigurationException e) {
|
|
|
|
|
throw new BusinessException("获取sxjg.properties配置文件失败,", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public WeaResult<Map<String, Object>> execute(Map<String, Object> params) {
|
|
|
|
|
Map<String, Object> rs =new HashMap<>();
|
|
|
|
|
String operate_flag = (String)params.get("operate_flag");
|
|
|
|
|
if("1".equals(operate_flag)) {
|
|
|
|
|
log.error("获取测评通知链接地址:>>>>>>>>>>>>>>>>>>>>>>Thread.currentThread().getName()"+Thread.currentThread().getName());
|
|
|
|
|
String Deadline = (String)params.get("Deadline");
|
|
|
|
|
String Email = (String)params.get("Email");
|
|
|
|
|
String JobId = (String)params.get("JobId");
|
|
|
|
|
String JobName = (String)params.get("JobName");
|
|
|
|
|
String Name = (String)params.get("Name");
|
|
|
|
|
String PaperIds = (String)params.get("PaperIds");
|
|
|
|
|
String s1[] = PaperIds.split("/");
|
|
|
|
|
PaperIds = s1[2];
|
|
|
|
|
String PersonId = (String)params.get("PersonId");
|
|
|
|
|
String orgCode = (String)params.get("orgcode");
|
|
|
|
|
log.error("orgCode:"+orgCode);
|
|
|
|
|
String companyId = SxjgUtil.getCompanyId(orgCode,jdbcTemplate);
|
|
|
|
|
String companyName = SxjgUtil.getCompanyName(orgCode,jdbcTemplate);
|
|
|
|
|
if(companyId.length()==0) {
|
|
|
|
|
log.error("没有找到对应匹配的companyId");
|
|
|
|
|
throw new RuntimeException("没有找到对应匹配的companyId");
|
|
|
|
|
}
|
|
|
|
|
log.error("Deadline:"+Deadline);
|
|
|
|
|
log.error("Email:"+Email);
|
|
|
|
|
log.error("JobId:"+JobId);
|
|
|
|
|
log.error("JobName:"+JobName);
|
|
|
|
|
log.error("Name:"+Name);
|
|
|
|
|
log.error("PaperIds:"+PaperIds);
|
|
|
|
|
log.error("PersonId:"+PersonId);
|
|
|
|
|
Date dateLine = SxjgUtil.getDateByTimestr(Deadline,"yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
long deadline1 = dateLine.getTime();
|
|
|
|
|
Deadline = String.valueOf(deadline1);
|
|
|
|
|
String url = SxjgUtil.getAssessNoticeUrl(Integer.parseInt(companyId),getSecret(),getAssessNoticeUrl(),Deadline,Email,JobId,JobName,Name,PaperIds,PersonId);
|
|
|
|
|
log.error("测评链接地址:"+url);
|
|
|
|
|
rs.put("url",url);
|
|
|
|
|
rs.put("companyName",companyName);
|
|
|
|
|
}else if("2".equals(operate_flag)) {//获取测评结果
|
|
|
|
|
Thread t = new Thread(() -> {
|
|
|
|
|
try{
|
|
|
|
|
log.error("获取测评结果... ...");
|
|
|
|
|
getAssessResult(jdbcTemplate);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("error::::::::");
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
t.start();
|
|
|
|
|
}
|
|
|
|
|
return WeaResult.success(rs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void getAssessResult(JdbcTemplate jdbcTemplate) throws Exception {
|
|
|
|
|
//根据组织,岗位id获取维度
|
|
|
|
|
List<Map<String,Object>> rs1 = SxjgUtil.getOrgJobLevelList(jdbcTemplate);
|
|
|
|
|
//遍历组织岗位维度zwssbm,position_id
|
|
|
|
|
if(rs1 != null && rs1.size() > 0) {
|
|
|
|
|
for(int i = 0;i<rs1.size();i++) {
|
|
|
|
|
Map<String, Object> rs2 = rs1.get(i);
|
|
|
|
|
String orgcode = (String)rs2.get("zwssbm");
|
|
|
|
|
String jobid = (String)rs2.get("position_id");
|
|
|
|
|
//根据岗位,组织 获取应聘者id
|
|
|
|
|
log.error("根据岗位,组织,应聘者获取维度>>>");
|
|
|
|
|
List<Map<String, Object>> rs3 = SxjgUtil.getUserids(jdbcTemplate,orgcode,jobid);
|
|
|
|
|
//同一个组织项目下的人员
|
|
|
|
|
if(rs3!=null&&rs3.size()>0) {
|
|
|
|
|
//手动逻辑分页
|
|
|
|
|
int total = rs3.size();
|
|
|
|
|
int page = total/50+1;
|
|
|
|
|
for(int a = 1; a <= page;a++) {
|
|
|
|
|
//第一页 0-49 第二页50-99 第三页100-149
|
|
|
|
|
int current = (a-1)*50;
|
|
|
|
|
int currenttotal = (current+50) >total ? total : (current+50);
|
|
|
|
|
String PersonIds = "";
|
|
|
|
|
for(int b = current; b < currenttotal; b++) {
|
|
|
|
|
Map<String, Object> rs4 = rs3.get(b);
|
|
|
|
|
String talent_id = (String) rs4.get("talent_id");
|
|
|
|
|
if(b == currenttotal-1) {
|
|
|
|
|
PersonIds += talent_id;
|
|
|
|
|
}else {
|
|
|
|
|
PersonIds += talent_id+",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String companyid = SxjgUtil.getCompanyId(orgcode,jdbcTemplate);
|
|
|
|
|
//获取第一页的结果同步
|
|
|
|
|
String getrs = SxjgUtil.getApiResult(jdbcTemplate,PersonIds,companyid,jobid,getAssessResultUrl(),getSecret());
|
|
|
|
|
log.error("智联测评:获取结果:"+getrs);
|
|
|
|
|
JSONObject rsobj = JSONObject.parseObject(getrs);
|
|
|
|
|
//有结果
|
|
|
|
|
if(rsobj.containsKey("JobId")) {
|
|
|
|
|
String jobid1 = rsobj.getString("JobId");
|
|
|
|
|
JSONArray Persons = rsobj.getJSONArray("Persons");
|
|
|
|
|
for(int c = 0;c<Persons.size();c++) {
|
|
|
|
|
JSONObject jsonObject = Persons.getJSONObject(c);
|
|
|
|
|
String PersonId = jsonObject.getString("PersonId");
|
|
|
|
|
JSONArray PersonPapers = jsonObject.getJSONArray("Papers");
|
|
|
|
|
for(int d = 0;d<PersonPapers.size();d++) {
|
|
|
|
|
JSONObject j1 = PersonPapers.getJSONObject(d);
|
|
|
|
|
int paperid =j1.getInteger("PaperId");
|
|
|
|
|
if(SxjgUtil.isExistPaper(jdbcTemplate,paperid,orgcode,jobid1)) {//匹配试卷id,更新结果
|
|
|
|
|
String shortpdf=j1.getString("PdfShortReportUrl");
|
|
|
|
|
String longpdf=j1.getString("PdfReportUrl");
|
|
|
|
|
String id = SxjgUtil.getIdByCause(jdbcTemplate,orgcode,jobid1,PersonId,paperid);
|
|
|
|
|
String username = SxjgUtil.getNameById(jdbcTemplate,id);
|
|
|
|
|
URL url = new URL(longpdf);
|
|
|
|
|
URLConnection conn = url.openConnection();
|
|
|
|
|
String fileName = "人岗匹配测试报告_"+username+"_详情_"+paperid+".pdf";
|
|
|
|
|
Long longpdfid = uploadfiletoYc(fileName,conn.getInputStream());
|
|
|
|
|
url = new URL(shortpdf);
|
|
|
|
|
conn = url.openConnection();
|
|
|
|
|
fileName = "人岗匹配测试报告_"+username+"_简介_"+paperid+".pdf";
|
|
|
|
|
Long shortpdfid = uploadfiletoYc(fileName,conn.getInputStream());
|
|
|
|
|
String TotalScore = j1.getBigDecimal("TotalScore").toString();
|
|
|
|
|
//更新 根据orgcode,jobid,personid,paperid
|
|
|
|
|
SxjgUtil.updateResultById(jdbcTemplate,id,shortpdfid,longpdfid,TotalScore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 上传附件
|
|
|
|
|
*/
|
|
|
|
|
public Long uploadfiletoYc(String fileName, InputStream inputStream) throws Exception{
|
|
|
|
|
String type = "application/pdf";
|
|
|
|
|
FileObj fileObj = null;
|
|
|
|
|
log.error("附件上传开始:>>>>>>>>");
|
|
|
|
|
RemoteUploadParam remoteUploadParam = new RemoteUploadParam(fileName,String.valueOf(System.currentTimeMillis()),"recruit");
|
|
|
|
|
remoteUploadParam.setCreateDoc(true);
|
|
|
|
|
remoteUploadParam.setSecretLevel(4);
|
|
|
|
|
remoteUploadParam.setTenantKey(this.getTenantKey());
|
|
|
|
|
fileObj = fileUploadService.uploadLocalFile(inputStream,Long.parseLong(getManagerid()),type,remoteUploadParam);
|
|
|
|
|
Long fieldid = fileObj.getFileid();
|
|
|
|
|
return fieldid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getCompanyId() {
|
|
|
|
|
return companyId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCompanyId(String companyId) {
|
|
|
|
|
int companyid1 = Integer.parseInt(companyId);
|
|
|
|
|
this.companyId = companyid1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getSecret() {
|
|
|
|
|
return secret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSecret(String secret) {
|
|
|
|
|
this.secret = secret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAssessNoticeUrl() {
|
|
|
|
|
return assessNoticeUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAssessNoticeUrl(String assessNoticeUrl) {
|
|
|
|
|
this.assessNoticeUrl = assessNoticeUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAssessResultUrl() {
|
|
|
|
|
return assessResultUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAssessResultUrl(String assessResultUrl) {
|
|
|
|
|
this.assessResultUrl = assessResultUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getTenantKey() {
|
|
|
|
|
return tenantKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setTenantKey(String tenantKey) {
|
|
|
|
|
this.tenantKey = tenantKey;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getManagerid() {
|
|
|
|
|
return managerid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setManagerid(String managerid) {
|
|
|
|
|
this.managerid = managerid;
|
|
|
|
|
}
|
|
|
|
|
}
|