diff --git a/src/com/api/resumestorage/web/ResumeIdentifyQliApi.java b/src/com/api/resumestorage/web/ResumeIdentifyQliApi.java deleted file mode 100644 index 351c32b..0000000 --- a/src/com/api/resumestorage/web/ResumeIdentifyQliApi.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.api.resumestorage.web; - -import com.engine.resumestorage.web.ResumeIdentifyQliAction; -import javax.ws.rs.Path; - -@Path("/resume/identifyQli") -public class ResumeIdentifyQliApi extends ResumeIdentifyQliAction { - public ResumeIdentifyQliApi() { - } -} diff --git a/src/com/api/resumestorage/web/ResumeStorageApi.java b/src/com/api/resumestorage/web/ResumeStorageApi.java deleted file mode 100644 index 9ef1a3f..0000000 --- a/src/com/api/resumestorage/web/ResumeStorageApi.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.api.resumestorage.web; - -import com.engine.resumestorage.web.ResumeStorageAction; -import javax.ws.rs.Path; - -@Path("/demo/resume") -public class ResumeStorageApi extends ResumeStorageAction { - public ResumeStorageApi() { - } -} diff --git a/src/com/engine/recruit/controller/ResumeRecognitionController.java b/src/com/engine/recruit/controller/ResumeRecognitionController.java index b6be5a6..05b93df 100644 --- a/src/com/engine/recruit/controller/ResumeRecognitionController.java +++ b/src/com/engine/recruit/controller/ResumeRecognitionController.java @@ -9,6 +9,7 @@ import weaver.hrm.User; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; @@ -34,4 +35,22 @@ public class ResumeRecognitionController { Map param = ParamUtil.request2Map(request); return new ResponseResult, Map>(user).run(getResumeRecognitionWrapper(user)::resumeUpload, param); } + + @POST + @Path("/importResume") + @Produces(MediaType.APPLICATION_JSON) + public String importResume(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getResumeRecognitionWrapper(user)::importResume, param); + } + + @GET + @Path("/fetchResume") + @Produces(MediaType.APPLICATION_JSON) + public String fetchResume(@Context HttpServletRequest request, @Context HttpServletResponse response) { + User user = HrmUserVarify.getUser(request, response); + Map param = ParamUtil.request2Map(request); + return new ResponseResult, Map>(user).run(getResumeRecognitionWrapper(user)::fetchResume, param); + } } diff --git a/src/com/engine/recruit/factory/RecruitButtonFactory.java b/src/com/engine/recruit/factory/RecruitButtonFactory.java index 8ee144a..69469b9 100644 --- a/src/com/engine/recruit/factory/RecruitButtonFactory.java +++ b/src/com/engine/recruit/factory/RecruitButtonFactory.java @@ -1,7 +1,9 @@ package com.engine.recruit.factory; import com.engine.core.impl.Service; +import com.engine.recruit.exception.CustomizeRunTimeException; import com.engine.recruit.service.RecruitButtonService; +import weaver.general.BaseBean; /** *

聚才林招聘

@@ -29,7 +31,8 @@ public class RecruitButtonFactory { } return (Class) clazz; } catch (ClassNotFoundException e) { - throw new RuntimeException(e); + new BaseBean().writeLog(e); + throw new CustomizeRunTimeException("操作按钮配置出错,未获取到按钮实现类[" + className + "]"); } diff --git a/src/com/engine/recruit/factory/ResumeRecognitionFactory.java b/src/com/engine/recruit/factory/ResumeRecognitionFactory.java new file mode 100644 index 0000000..d2db211 --- /dev/null +++ b/src/com/engine/recruit/factory/ResumeRecognitionFactory.java @@ -0,0 +1,37 @@ +package com.engine.recruit.factory; + +import com.engine.core.impl.Service; +import com.engine.recruit.exception.CustomizeRunTimeException; +import com.engine.recruit.service.ResumeRecognitionService; +import weaver.general.BaseBean; + +/** + * @author:dxfeng + * @createTime: 2024/01/09 + * @version: 1.0 + */ +public class ResumeRecognitionFactory { + + /** + * 根据类的全路径获取类对象 + * + * @param className 类全路径 + * @param + * @return + */ + public static Class getClass(String className) { + Class clazz; + try { + clazz = Class.forName(className); + if (!ResumeRecognitionService.class.isAssignableFrom(clazz)) { + throw new IllegalArgumentException("该类未实现ResumeRecognitionService"); + } + return (Class) clazz; + } catch (ClassNotFoundException e) { + new BaseBean().writeLog(e); + throw new CustomizeRunTimeException("简历识别配置出错,未获取到解析实现类[" + className + "]"); + } + + + } +} diff --git a/src/com/engine/recruit/service/WorkPlanSerivice.java b/src/com/engine/recruit/service/WorkPlanSerivice.java index 256f07d..ca7d1ce 100644 --- a/src/com/engine/recruit/service/WorkPlanSerivice.java +++ b/src/com/engine/recruit/service/WorkPlanSerivice.java @@ -6,7 +6,6 @@ import com.engine.recruit.entity.workplan.WorkPlanCreateParams; /** * @Author liang.cheng * @Date 2023/10/17 10:50 AM - * @Description: TODO * @Version 1.0 */ public interface WorkPlanSerivice { diff --git a/src/com/engine/recruit/service/impl/ResumeRecognitionServiceImpl.java b/src/com/engine/recruit/service/impl/ResumeRecognitionServiceImpl.java index 93a2a89..b6cf2db 100644 --- a/src/com/engine/recruit/service/impl/ResumeRecognitionServiceImpl.java +++ b/src/com/engine/recruit/service/impl/ResumeRecognitionServiceImpl.java @@ -1,19 +1,20 @@ package com.engine.recruit.service.impl; +import cn.hutool.core.convert.Convert; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; -import com.engine.core.exception.ECException; import com.engine.core.impl.Service; import com.engine.recruit.conn.ApplicantCommonInfo; +import com.engine.recruit.conn.CheckRepeatResume; import com.engine.recruit.conn.ModeBrowserCommonInfo; +import com.engine.recruit.conn.RecruitRecordSet; +import com.engine.recruit.enums.ApplicationStatusEnum; import com.engine.recruit.exception.CustomizeRunTimeException; import com.engine.recruit.service.ResumeRecognitionService; -import com.engine.recruit.util.HttpUtils; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.IOUtils; +import com.weaver.formmodel.data.model.Formfield; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; -import org.apache.http.HttpResponse; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; @@ -21,22 +22,20 @@ import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import weaver.conn.RecordSet; import weaver.file.ImageFileManager; -import weaver.general.BaseBean; +import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil; import weaver.general.Util; -import java.io.InputStream; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; +import java.util.stream.Collectors; /** * @author:dxfeng @@ -44,53 +43,100 @@ import java.util.function.Function; * @version: 1.0 */ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecognitionService { - /** - * 简历识别类型 - */ - //private static final String OCR_TYPE = RecruitModeUtil.getRecruitPropValue("OCR_TYPE"); - private static final String OCR_TYPE = "1"; + @Override public Map resumeUpload(Map param) { Map returnMap = new HashMap<>(16); - returnMap.put("isOcr", true); - if (StringUtils.isBlank(OCR_TYPE)) { - returnMap.put("isOcr", false); - return returnMap; - } String resumeId = Util.null2String(param.get("resumeId")); int imageField = ApplicantCommonInfo.getImageFieldByDocId(resumeId); if (-1 == imageField) { throw new CustomizeRunTimeException("原始简历文件获取失败,请重新上传原始简历"); } - // 调用千里聆服务 - if ("1".equals(OCR_TYPE)) { - qllResumeUpload(imageField, returnMap); + qllResumeUpload(imageField, returnMap, true); + returnMap.put("isOcr", true); + return returnMap; + } + + @Override + public Map importResume(Map param) { + Map returnMap = new HashMap<>(); + String resumeId = Util.null2String(param.get("resumeId")); + Map uploadDataMap = new HashMap<>(); + qllResumeUpload(Convert.toInt(resumeId), uploadDataMap, false); + + Map resumeData = (Map) uploadDataMap.get("data"); + // 添加原始附件字段信息 + int secCategory = Convert.toInt(RecruitModeUtil.getRecruitPropValue("APPLICANTS_RESUMES_CATEGORY")); + try { + int docId = RecruitModeUtil.createDocId(secCategory, Convert.toInt(resumeId), user); + resumeData.put("ysjl", docId); + } catch (Exception e) { + throw new RuntimeException(e); + } + List> studyList = (List>) resumeData.remove("jyjl"); + List> workList = (List>) resumeData.remove("gzjl"); + + // 状态 + resumeData.put("zt", ApplicationStatusEnum.DISTRIBUTION.getValue()); + + List fieldList = RecruitModeUtil.getFieldList("uf_jcl_yppc"); + Set keySet = fieldList.stream().map(Formfield::getFieldname).collect(Collectors.toSet()); + + // 移除不在 keySet 中的键值对 + resumeData.entrySet().removeIf(entry -> !keySet.contains(entry.getKey())); + + + // 判断简历信息 + Map map = CheckRepeatResume.getInstance().insertResumeAndReturn(resumeData); + String mainId = Util.null2String(map.get("mainId")); + String sourceId = Util.null2String(map.get("sourceId")); + returnMap.put("mainId", mainId); + returnMap.put("sourceId", sourceId); + returnMap.put("id", StringUtils.isNotBlank(sourceId) ? sourceId : mainId); + + // 插入明细表数据 + if (CollectionUtils.isNotEmpty(studyList)) { + for (Map studMap : studyList) { + studMap.put("mainid", mainId); + RecruitRecordSet.insertData(studMap, "uf_jcl_yppc_dt1"); + } } - // 调用阿里云服务 - if ("2".equals(OCR_TYPE)) { - alyResumeUpload(imageField, returnMap); + if (CollectionUtils.isNotEmpty(workList)) { + for (Map workMap : workList) { + workMap.put("mainid", mainId); + RecruitRecordSet.insertData(workMap, "uf_jcl_yppc_dt2"); + } } return returnMap; } - @Override - public Map importResume(Map param) { - String resumeId = Util.null2String(param.get("resumeId")); - Map uploadDataMap = resumeUpload(param); - Map resumeData = (Map) uploadDataMap.get("data"); - // 添加原始附件字段信息 - - // 校验是否可以 - - return null; - } - @Override public Map fetchResume(Map param) { - return null; + String id = Util.null2String(param.get("id")); + String sql = "select * from uf_jcl_yppc where id = ? "; + RecordSet rs = new RecordSet(); + rs.executeQuery(sql, id); + Map dataMap = RecruitRecordSet.getSingleRecordMap(rs); + + List fieldList = RecruitModeUtil.getFieldList("uf_jcl_yppc"); + Map fieldMap = fieldList.stream().collect(Collectors.toMap(Formfield::getFieldname, item -> item, (k1, k2) -> k1)); + + for (String key : dataMap.keySet()) { + Object value = dataMap.get(key); + if (StringUtils.isBlank(Convert.toStr(value))) { + continue; + } + // 计算新的value值 + Formfield formfield = fieldMap.get(key); + value = RecruitModeUtil.getFieldShowName(formfield, Convert.toStr(value)).replaceAll("<[^>]*>", ""); + // 更新value值 + dataMap.put(key, value); + } + + return dataMap; } @@ -98,7 +144,7 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog * @param resumeId 简历ID * @param returnMap 响应集合 */ - private void qllResumeUpload(int resumeId, Map returnMap) { + private void qllResumeUpload(int resumeId, Map returnMap, boolean isCard) { String response = doQllPost(resumeId); if (StringUtils.isBlank(response)) { throw new CustomizeRunTimeException("千里聆接口调用失败,响应结果为空"); @@ -114,135 +160,18 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog throw new CustomizeRunTimeException("调用千里聆接口失败,失败原因:" + resultall.getString("info")); } JSONObject result = resultall.getJSONObject("result"); - Map dataMap = parseQllJsonToMap(result); + Map dataMap = parseQllJsonToMap(result, isCard); returnMap.put("data", dataMap); } - /** - * @param resumeId 简历ID - * @param returnMap 响应集合 - */ - private void alyResumeUpload(int resumeId, Map returnMap) { - String response = doAlyPost(resumeId); - JSONObject all = JSONObject.parseObject(response); - String errorMsg = all.getString("error_msg"); - if (!"成功".equals(errorMsg)) { - throw new CustomizeRunTimeException("阿里云简历识别失败"); - } - JSONObject parseObject = all.getJSONObject("data").getJSONObject("cv_parse"); - Map saveResume = parseAlyJsonToMap(parseObject); - returnMap.put("data", saveResume); - } - /** * 千里聆解析字段内容处理 * * @param obj * @return */ - private Map parseAlyJsonToMap(JSONObject obj) { - JSONObject basicInfo = obj.getJSONObject("basic_info"); - JSONObject contact = obj.getJSONObject("contact"); - JSONObject jobObjective = obj.getJSONObject("job_objective"); - - Map dataMap = new HashMap<>(16); - // 姓名 - String xm = basicInfo.getString("name"); - dataMap.put("xm", xm); - // 电子邮箱 - String dzyx = contact.getString("email"); - dataMap.put("dzyx", dzyx); - // 手机号码 - String sjhm = contact.getString("mobile"); - dataMap.put("sjhm", sjhm); - // 年龄 - String nl = basicInfo.getString("age"); - dataMap.put("nl", nl); - // 出生日期 - String csrq = basicInfo.getString("birthday"); - dataMap.put("csrq", parseDateObject(csrq)); - // 民族 - String mz = basicInfo.getString("nation"); - dataMap.put("mz", mz); - // 性别 - String xb = "女".equals(basicInfo.getString("gender")) ? "1" : "0"; - dataMap.put("xb", xb); - // 体重(KG) - // 身高(CM) - // 籍贯 - dataMap.put("jg", basicInfo.getString("native_place")); - // 婚姻状况 - // 当前所在地 - dataMap.put("jzd", basicInfo.getString("extract_location")); - // 政治面貌 - // 在职状态 - // 工作经验 - dataMap.put("gzjy", basicInfo.getString("work_years_original")); - // 最高学位 - // 最高学历 - dataMap.put("zgxl", getBrowserArray(basicInfo.getString("highest_degree"), this::getEducationLevelArray)); - - // 毕业院校 - String byyx = basicInfo.getString("graduate_school"); - dataMap.put("byyx", byyx); - // 期望税前月薪(K) - String qwxz = jobObjective.getString("expect_salary_upper"); - dataMap.put("qwxz", qwxz); - // 现税前月薪(K) - // 自我评价 - String zwpj = obj.getString("self_evaluate"); - dataMap.put("zwpj", zwpj); - - // 明细表数据 - // 教育经历 - JSONArray jyjl = obj.getJSONArray("educations"); - List> studyList = new ArrayList<>(); - if (null != jyjl && jyjl.size() > 0) { - for (int i = 0; i < jyjl.size(); i++) { - JSONObject o = (JSONObject) jyjl.get(i); - String startTime = o.getString("start_time"); - String endTime = o.getString("end_time"); - String studyDate = startTime + "-" + endTime; - Map studyMap = new HashMap<>(getDateRange(studyDate, true)); - studyMap.put("xxmc", o.getString("school")); - studyMap.put("xl", getBrowserArray(o.getString("degree"), this::getEducationLevelArray)); - studyMap.put("zy", o.getString("major")); - studyList.add(studyMap); - } - } - dataMap.put("jyjl", studyList); - - // 工作经历 - JSONArray gzjl = obj.getJSONArray("occupations"); - List> workList = new ArrayList<>(); - if (null != gzjl && gzjl.size() > 0) { - for (int i = 0; i < gzjl.size(); i++) { - JSONObject o = (JSONObject) gzjl.get(i); - String startTime = o.getString("start_time"); - String endTime = o.getString("end_time"); - String workDate = startTime + "-" + endTime; - Map workMap = new HashMap<>(getDateRange(workDate, false)); - workMap.put("gsmc", o.getString("company")); - workMap.put("gw", o.getString("title")); - workMap.put("gzzz", o.getString("desc")); - workList.add(workMap); - } - } - - dataMap.put("gzjl", workList); - - return dataMap; - } - - - /** - * 千里聆解析字段内容处理 - * - * @param obj - * @return - */ - private Map parseQllJsonToMap(JSONObject obj) { + private Map parseQllJsonToMap(JSONObject obj, boolean isCard) { Map dataMap = new HashMap<>(16); // 姓名 String xm = parseArray(obj.getJSONArray("姓名")); @@ -260,8 +189,8 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog String csrq = parseArray(obj.getJSONArray("出生日期")); dataMap.put("csrq", parseDateObject(csrq)); // 民族 - // 性别 - String xb = "男".equals(parseArray(obj.getJSONArray("性别"))) ? "0" : "1"; + // 性别 默认为男 + String xb = "女".equals(parseArray(obj.getJSONArray("性别"))) ? "1" : "0"; dataMap.put("xb", xb); // 体重(KG) // 身高(CM) @@ -275,9 +204,17 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog // 工作经验 dataMap.put("gzjy", parseArray(obj.getJSONArray("工作经验"))); // 最高学位 - dataMap.put("zgxw", getBrowserArray(parseArray(obj.getJSONArray("最高学位")), this::getDegreeArray)); + List> zgxw = getBrowserArray(parseArray(obj.getJSONArray("最高学位")), this::getDegreeArray); + dataMap.put("zgxw", zgxw); + if (!isCard && CollectionUtils.isNotEmpty(zgxw)) { + dataMap.put("zgxw", zgxw.stream().map(item -> item.get("id")).collect(Collectors.joining(","))); + } // 最高学历 - dataMap.put("zgxl", getBrowserArray(parseArray(obj.getJSONArray("最高学历")), this::getEducationLevelArray)); + List> zgxl = getBrowserArray(parseArray(obj.getJSONArray("最高学历")), this::getEducationLevelArray); + dataMap.put("zgxl", zgxl); + if (!isCard && CollectionUtils.isNotEmpty(zgxl)) { + dataMap.put("zgxl", zgxl.stream().map(item -> item.get("id")).collect(Collectors.joining(","))); + } // 专业 String zy = parseArray(obj.getJSONArray("专业")); @@ -306,7 +243,11 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog String studyDate = o.getString("就读时期"); Map studyMap = new HashMap<>(getDateRange(studyDate, true)); studyMap.put("xxmc", o.getString("院校")); - studyMap.put("xl", getBrowserArray(o.getString("学历"), this::getEducationLevelArray)); + List> xl = getBrowserArray(o.getString("学历"), this::getEducationLevelArray); + studyMap.put("xl", xl); + if (!isCard && CollectionUtils.isNotEmpty(xl)) { + studyMap.put("xl", xl.stream().map(item -> item.get("id")).collect(Collectors.joining(","))); + } studyMap.put("zy", o.getString("专业")); studyList.add(studyMap); } @@ -359,10 +300,12 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog * @return */ private String doQllPost(int resumeId) { - BaseBean bean = new BaseBean(); - String url = bean.getPropValue("resume_qianliling", "qianlilingurl"); - String appId = bean.getPropValue("resume_qianliling", "appId"); - String appSecret = bean.getPropValue("resume_qianliling", "appSecret"); + String url = RecruitModeUtil.getRecruitPropValue("qianlilingurl"); + String appId = RecruitModeUtil.getRecruitPropValue("appId"); + String appSecret = RecruitModeUtil.getRecruitPropValue("appSecret"); + if (StringUtils.isAnyBlank(url, appId, appSecret)) { + throw new CustomizeRunTimeException("千里聆配置出错,请检查配置文件"); + } long currentTime = System.currentTimeMillis(); ImageFileManager manager = new ImageFileManager(); @@ -388,37 +331,6 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog } } - /** - * @param resumeId - * @return - */ - private String doAlyPost(int resumeId) { - try { - BaseBean bean = new BaseBean(); - String parseHost = bean.getPropValue("youyun", "host"); - String path = bean.getPropValue("youyun", "path"); - String method = bean.getPropValue("youyun", "method"); - String appcode = bean.getPropValue("youyun", "appcode"); - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(resumeId); - Map headers = new HashMap<>(2); - headers.put("Authorization", "APPCODE " + appcode); - headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); - Map queryMap = new HashMap<>(1); - Map bodyMap = new HashMap<>(2); - InputStream inputStream = manager.getInputStream(); - byte[] bytes = IOUtils.toByteArray(inputStream); - String base64 = Base64.encodeBase64String(bytes); - bodyMap.put("content", base64); - String fileName = manager.getImageFileName(); - String suffixType = fileName.substring(fileName.lastIndexOf('.') + 1); - bodyMap.put("ext", suffixType); - HttpResponse response = HttpUtils.doPost(parseHost, path, method, headers, queryMap, bodyMap); - return EntityUtils.toString(response.getEntity()); - } catch (Exception var10) { - throw new ECException("简历解析失败!详情:" + var10.getMessage()); - } - } /** * 千里聆签名 @@ -467,7 +379,7 @@ public class ResumeRecognitionServiceImpl extends Service implements ResumeRecog } } - return rs.toString(); + return StringUtils.isBlank(rs) ? null : rs.toString(); } diff --git a/src/com/engine/recruit/util/HttpUtils.java b/src/com/engine/recruit/util/HttpUtils.java deleted file mode 100644 index c0131b5..0000000 --- a/src/com/engine/recruit/util/HttpUtils.java +++ /dev/null @@ -1,314 +0,0 @@ -package com.engine.recruit.util; - -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.message.BasicNameValuePair; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class HttpUtils { - /** - * get - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @return - * @throws Exception - */ - public static HttpResponse doGet(String host, String path, String method, - Map headers, - Map querys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpGet request = new HttpGet(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - return httpClient.execute(request); - } - - /** - * post form - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param bodys - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - Map bodys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (bodys != null) { - List nameValuePairList = new ArrayList(); - - for (String key : bodys.keySet()) { - nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); - } - UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); - formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); - request.setEntity(formEntity); - } - - return httpClient.execute(request); - } - - /** - * Post String - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - String body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (StringUtils.isNotBlank(body)) { - request.setEntity(new StringEntity(body, "utf-8")); - } - - return httpClient.execute(request); - } - - /** - * Post stream - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - byte[] body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (body != null) { - request.setEntity(new ByteArrayEntity(body)); - } - - return httpClient.execute(request); - } - - /** - * Put String - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPut(String host, String path, String method, - Map headers, - Map querys, - String body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPut request = new HttpPut(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (StringUtils.isNotBlank(body)) { - request.setEntity(new StringEntity(body, "utf-8")); - } - - return httpClient.execute(request); - } - - /** - * Put stream - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPut(String host, String path, String method, - Map headers, - Map querys, - byte[] body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPut request = new HttpPut(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (body != null) { - request.setEntity(new ByteArrayEntity(body)); - } - - return httpClient.execute(request); - } - - /** - * Delete - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @return - * @throws Exception - */ - public static HttpResponse doDelete(String host, String path, String method, - Map headers, - Map querys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - return httpClient.execute(request); - } - - private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException { - StringBuilder sbUrl = new StringBuilder(); - sbUrl.append(host); - if (!StringUtils.isBlank(path)) { - sbUrl.append(path); - } - if (null != querys) { - StringBuilder sbQuery = new StringBuilder(); - for (Map.Entry query : querys.entrySet()) { - if (0 < sbQuery.length()) { - sbQuery.append("&"); - } - if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { - sbQuery.append(query.getValue()); - } - if (!StringUtils.isBlank(query.getKey())) { - sbQuery.append(query.getKey()); - if (!StringUtils.isBlank(query.getValue())) { - sbQuery.append("="); - sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); - } - } - } - if (0 < sbQuery.length()) { - sbUrl.append("?").append(sbQuery); - } - } - - return sbUrl.toString(); - } - - private static HttpClient wrapClient(String host) { - HttpClient httpClient = new DefaultHttpClient(); - if (host.startsWith("https://")) { - sslClient(httpClient); - } - - return httpClient; - } - - private static void sslClient(HttpClient httpClient) { - try { - SSLContext ctx = SSLContext.getInstance("TLS"); - X509TrustManager tm = new X509TrustManager() { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - - public void checkClientTrusted(X509Certificate[] xcs, String str) { - - } - - public void checkServerTrusted(X509Certificate[] xcs, String str) { - - } - }; - ctx.init(null, new TrustManager[]{tm}, null); - SSLSocketFactory ssf = new SSLSocketFactory(ctx); - ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - ClientConnectionManager ccm = httpClient.getConnectionManager(); - SchemeRegistry registry = ccm.getSchemeRegistry(); - registry.register(new Scheme("https", 443, ssf)); - } catch (KeyManagementException ex) { - throw new RuntimeException(ex); - } catch (NoSuchAlgorithmException ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/src/com/engine/recruit/wrapper/ResumeRecognitionWrapper.java b/src/com/engine/recruit/wrapper/ResumeRecognitionWrapper.java index b8b6263..e9d8c9b 100644 --- a/src/com/engine/recruit/wrapper/ResumeRecognitionWrapper.java +++ b/src/com/engine/recruit/wrapper/ResumeRecognitionWrapper.java @@ -2,8 +2,10 @@ package com.engine.recruit.wrapper; import com.engine.common.util.ServiceUtil; import com.engine.core.impl.Service; +import com.engine.recruit.factory.ResumeRecognitionFactory; import com.engine.recruit.service.ResumeRecognitionService; -import com.engine.recruit.service.impl.ResumeRecognitionServiceImpl; +import org.apache.commons.lang3.StringUtils; +import weaver.formmode.recruit.modeexpand.util.RecruitModeUtil; import weaver.hrm.User; import java.util.Map; @@ -16,10 +18,27 @@ import java.util.Map; public class ResumeRecognitionWrapper extends Service { private ResumeRecognitionService getResumeRecognitionService(User user) { - return ServiceUtil.getService(ResumeRecognitionServiceImpl.class, user); + return ServiceUtil.getService(ResumeRecognitionFactory.getClass(RecruitModeUtil.OCR_TYPE), user); } public Map resumeUpload(Map param) { + if (StringUtils.isBlank(RecruitModeUtil.OCR_TYPE)) { + return null; + } return getResumeRecognitionService(user).resumeUpload(param); } + + public Map importResume(Map param) { + if (StringUtils.isBlank(RecruitModeUtil.OCR_TYPE)) { + return null; + } + return getResumeRecognitionService(user).importResume(param); + } + + public Map fetchResume(Map param) { + if (StringUtils.isBlank(RecruitModeUtil.OCR_TYPE)) { + return null; + } + return getResumeRecognitionService(user).fetchResume(param); + } } diff --git a/src/com/engine/resumestorage/service/ResumeIdentifyService.java b/src/com/engine/resumestorage/service/ResumeIdentifyService.java deleted file mode 100644 index 8d21998..0000000 --- a/src/com/engine/resumestorage/service/ResumeIdentifyService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.engine.resumestorage.service; - -import java.util.Map; - -public interface ResumeIdentifyService { - int saveResumeByImageFileId(int var1) throws Exception; - - int saveResumeInDB(Map var1) throws Exception; - - Map queryByDBId(String var1) throws Exception; - - boolean deleteById(String var1) throws Exception; -} diff --git a/src/com/engine/resumestorage/service/ResumeStorageService.java b/src/com/engine/resumestorage/service/ResumeStorageService.java deleted file mode 100644 index 786f90b..0000000 --- a/src/com/engine/resumestorage/service/ResumeStorageService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.engine.resumestorage.service; - -import java.util.Map; - -public interface ResumeStorageService { - int saveResumeByImageFileId(int var1) throws Exception; - - int saveResumeInDB(Map var1) throws Exception; - - Map queryByDBId(String var1) throws Exception; - - boolean deleteById(String var1) throws Exception; -} diff --git a/src/com/engine/resumestorage/service/impl/ResumeIdentifyServiceImpl.java b/src/com/engine/resumestorage/service/impl/ResumeIdentifyServiceImpl.java deleted file mode 100644 index f7d7e01..0000000 --- a/src/com/engine/resumestorage/service/impl/ResumeIdentifyServiceImpl.java +++ /dev/null @@ -1,447 +0,0 @@ -package com.engine.resumestorage.service.impl; - -import cn.hutool.core.date.DateUtil; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.engine.core.exception.ECException; -import com.engine.core.impl.Service; -import com.engine.resumestorage.service.ResumeIdentifyService; -import com.engine.resumestorage.util.ParseResumeQliUtil; -import com.engine.resumestorage.util.Sql; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.apache.commons.lang3.StringUtils; -import weaver.conn.RecordSetTrans; -import weaver.formmode.setup.ModeRightInfo; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -public class ResumeIdentifyServiceImpl extends Service implements ResumeIdentifyService { - private final Logger log = LoggerFactory.getLogger(ResumeIdentifyService.class); - BaseBean bb = new BaseBean(); - String formmodeid_tmp; - String sfsymr; - - public ResumeIdentifyServiceImpl() { - this.formmodeid_tmp = this.bb.getPropValue("resume_qianliling", "model.id"); - this.sfsymr = this.bb.getPropValue("resume_qianliling", "sfsymr"); - } - - public int saveResumeByImageFileId(int imageFileId) throws Exception { - new HashMap(); - String response = ParseResumeQliUtil.doParseHostPost(imageFileId); - this.log.info("千里聆接口返回值:" + response); - if (response.length() == 0) { - this.log.info("调用千里零接口失败,返回值为空"); - throw new Exception("调用千里零接口失败,返回值为空"); - } else { - JSONObject all = JSONObject.parseObject(response); - if (!all.getBoolean("isSuccess")) { - this.log.info("调用千里零接口失败,接口不通"); - throw new Exception("调用千里零接口失败,接口不通"); - } else { - JSONObject resultall = all.getJSONObject("data"); - String status = resultall.getString("state"); - if ("fail".equals(status)) { - this.log.info("调用千里零接口失败,失败原因:" + resultall.getString("info")); - throw new Exception("调用千里零接口失败,失败原因:" + resultall.getString("info")); - } else { - JSONObject result = resultall.getJSONObject("result"); - Map saveResume = this.parseJsonToMap(result); - return this.saveResumeInDB(saveResume); - } - } - } - } - - public int saveResumeInDB(Map fields) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("resume_qianliling", "jlk.tablename"); - } - - RecordSetTrans rst = new RecordSetTrans(); - rst.setAutoCommit(false); - List field = new ArrayList(); - List value1 = new ArrayList(); - List value = new ArrayList(); - fields.forEach((key, v) -> { - if (StringUtils.isNotEmpty(v)) { - field.add(key); - value.add(v); - value1.add("?"); - } - - }); - String sql = "insert into " + tablename + "(" + String.join(",", field) + ") values(" + String.join(",", value1) + ")"; - this.log.error("test--------------------"); - this.log.error(sql); - this.log.error("test--------------------"); - - try { - boolean flag = rst.executeUpdate(sql, new Object[]{value}); - rst.commit(); - if (flag) { - String idSql = "SELECT max(id) as mid from " + tablename; - String id = Sql.querySingleField(idSql, "mid"); - this.permissionReconstruction(Util.getIntValue(id)); - return Integer.parseInt(id); - } else { - return -1; - } - } catch (Exception var11) { - var11.printStackTrace(); - rst.rollback(); - this.log.error(var11); - throw new ECException("简历更新失败"); - } - } - - private void permissionReconstruction(int billId) { - ModeRightInfo ModeRightInfo = new ModeRightInfo(); - ModeRightInfo.setNewRight(true); - ModeRightInfo.editModeDataShare(1, Util.getIntValue(this.formmodeid_tmp), billId); - } - - public Map queryByDBId(String resumeid) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("youyun", "tablename"); - } - - String sql = "select * from " + tablename + " where id=" + resumeid; - return Sql.querySingleRow(sql); - } - - public boolean deleteById(String resumeid) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("youyun", "tablename"); - } - - String sql = "delete " + tablename + " where id=" + resumeid; - RecordSetTrans rst = new RecordSetTrans(); - rst.setAutoCommit(false); - - try { - rst.executeUpdate(sql, new Object[0]); - rst.commit(); - return true; - } catch (Exception var6) { - rst.rollback(); - throw new Exception(var6); - } - } - - private Map parseJsonToMap(JSONObject obj) { - Map rs = new HashMap(); - if ("1".equals(this.sfsymr)) { - String v; - if (obj.containsKey("姓名")) { - v = this.bb.getPropValue("resume_qianliling", "rmxm"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "rmxm"), this.parseArray(obj.getJSONArray("姓名"))); - } - } - - if (obj.containsKey("性别")) { - v = this.bb.getPropValue("resume_qianliling", "xb"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "xb"), this.parseArray(obj.getJSONArray("性别")).equals("男") ? "0" : "1"); - } - } - - if (obj.containsKey("出生日期")) { - v = this.bb.getPropValue("resume_qianliling", "csrq"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "csrq"), this.parseArray(obj.getJSONArray("出生日期"))); - } - } - - if (obj.containsKey("籍贯")) { - v = this.bb.getPropValue("resume_qianliling", "jg"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "jg"), this.parseArray(obj.getJSONArray("籍贯"))); - } - } - - if (obj.containsKey("手机号")) { - v = this.bb.getPropValue("resume_qianliling", "sjhm"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "sjhm"), this.parseArray(obj.getJSONArray("手机号"))); - } - } - - if (obj.containsKey("电子邮箱")) { - v = this.bb.getPropValue("resume_qianliling", "email"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "email"), this.parseArray(obj.getJSONArray("电子邮箱"))); - } - } - - if (obj.containsKey("微信")) { - v = this.bb.getPropValue("resume_qianliling", "wx"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "wx"), this.parseArray(obj.getJSONArray("微信"))); - } - } - - if (obj.containsKey("QQ")) { - v = this.bb.getPropValue("resume_qianliling", "qq"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "qq"), this.parseArray(obj.getJSONArray("QQ"))); - } - } - - if (obj.containsKey("现居住地")) { - v = this.bb.getPropValue("resume_qianliling", "jzd"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "jzd"), this.parseArray(obj.getJSONArray("现居住地"))); - } - } - - if (obj.containsKey("爱好")) { - v = this.bb.getPropValue("resume_qianliling", "ah"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "ah"), this.parseArray(obj.getJSONArray("爱好"))); - } - } - - if (obj.containsKey("个人评价")) { - v = this.bb.getPropValue("resume_qianliling", "grpj"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "grpj"), this.parseArray(obj.getJSONArray("个人评价"))); - } - } - - if (obj.containsKey("学业信息")) { - v = this.bb.getPropValue("resume_qianliling", "xyxg"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "xyxg"), obj.getJSONArray("学业信息").toJSONString()); - } - } - - if (obj.containsKey("毕业时间")) { - v = this.bb.getPropValue("resume_qianliling", "bysj"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "bysj"), this.parseArray(obj.getJSONArray("毕业时间"))); - } - } - - if (obj.containsKey("最高学历")) { - v = this.bb.getPropValue("resume_qianliling", "zgxl"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "zgxl"), this.parseArray(obj.getJSONArray("最高学历"))); - } - } - - if (obj.containsKey("专业技能")) { - v = this.bb.getPropValue("resume_qianliling", "zyjn"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "zyjn"), this.parseArray(obj.getJSONArray("专业技能"))); - } - } - - if (obj.containsKey("实习经历")) { - v = this.bb.getPropValue("resume_qianliling", "sxjl"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "sxjl"), this.parseArray(obj.getJSONArray("实习经历"))); - } - } - - if (obj.containsKey("英语水平")) { - v = this.bb.getPropValue("resume_qianliling", "yysp"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "yysp"), this.parseArray(obj.getJSONArray("英语水平"))); - } - } - - if (obj.containsKey("技能证书")) { - v = this.bb.getPropValue("resume_qianliling", "jnzs"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "jnzs"), this.parseArray(obj.getJSONArray("技能证书"))); - } - } - - if (obj.containsKey("校园经历")) { - v = this.bb.getPropValue("resume_qianliling", "xyjl"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "xyjl"), this.parseArray(obj.getJSONArray("校园经历"))); - } - } - - if (obj.containsKey("工作信息")) { - v = this.bb.getPropValue("resume_qianliling", "gzxg"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "gzxg"), obj.getJSONArray("工作信息").toJSONString()); - } - } - - if (obj.containsKey("期望从事岗位")) { - v = this.bb.getPropValue("resume_qianliling", "qwcsgw"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "qwcsgw"), this.parseArray(obj.getJSONArray("期望从事岗位"))); - } - } - - if (obj.containsKey("工作经验")) { - v = this.bb.getPropValue("resume_qianliling", "gzjy1"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "gzjy1"), this.parseArray(obj.getJSONArray("工作经验"))); - } - } - - if (obj.containsKey("期望薪资")) { - v = this.bb.getPropValue("resume_qianliling", "qwxz"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "qwxz"), this.parseArray(obj.getJSONArray("期望薪资"))); - } - } - - if (obj.containsKey("期望工作地点")) { - v = this.bb.getPropValue("resume_qianliling", "qwgzdd"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "qwgzdd"), this.parseArray(obj.getJSONArray("期望工作地点"))); - } - } - - if (obj.containsKey("项目经历")) { - v = this.bb.getPropValue("resume_qianliling", "xmjl"); - if (v != null && v.length() > 0) { - rs.put(this.bb.getPropValue("resume_qianliling", "xmjl"), this.parseArray(obj.getJSONArray("项目经历"))); - } - } - } else { - if (obj.containsKey("姓名")) { - rs.put("rmxm", this.parseArray(obj.getJSONArray("姓名"))); - } - - if (obj.containsKey("性别")) { - rs.put("xb", this.parseArray(obj.getJSONArray("性别")).equals("男") ? "0" : "1"); - } - - if (obj.containsKey("出生日期")) { - rs.put("csrq", this.parseArray(obj.getJSONArray("出生日期"))); - } - - if (obj.containsKey("籍贯")) { - rs.put("jg", this.parseArray(obj.getJSONArray("籍贯"))); - } - - if (obj.containsKey("手机号")) { - rs.put("sjhm", this.parseArray(obj.getJSONArray("手机号"))); - } - - if (obj.containsKey("电子邮箱")) { - rs.put("email", this.parseArray(obj.getJSONArray("电子邮箱"))); - } - - if (obj.containsKey("微信")) { - rs.put("wx", this.parseArray(obj.getJSONArray("微信"))); - } - - if (obj.containsKey("QQ")) { - rs.put("qq", this.parseArray(obj.getJSONArray("QQ"))); - } - - if (obj.containsKey("现居住地")) { - rs.put("jzd", this.parseArray(obj.getJSONArray("现居住地"))); - } - - if (obj.containsKey("爱好")) { - rs.put("ah", this.parseArray(obj.getJSONArray("爱好"))); - } - - if (obj.containsKey("个人评价")) { - rs.put("grpj", this.parseArray(obj.getJSONArray("个人评价"))); - } - - if (obj.containsKey("学业信息")) { - rs.put("xyxg", obj.getJSONArray("学业信息").toJSONString()); - } - - if (obj.containsKey("毕业时间")) { - rs.put("bysj", this.parseArray(obj.getJSONArray("毕业时间"))); - } - - if (obj.containsKey("最高学历")) { - rs.put("zgxlwb", this.parseArray(obj.getJSONArray("最高学历"))); - } - - if (obj.containsKey("最高学位")) { - rs.put("zgxw", this.parseArray(obj.getJSONArray("最高学位"))); - } - - if (obj.containsKey("专业技能")) { - rs.put("zyjn", this.parseArray(obj.getJSONArray("专业技能"))); - } - - if (obj.containsKey("实习经历")) { - rs.put("sxjl", this.parseArray(obj.getJSONArray("实习经历"))); - } - - if (obj.containsKey("英语水平")) { - rs.put("yysp", this.parseArray(obj.getJSONArray("英语水平"))); - } - - if (obj.containsKey("技能证书")) { - rs.put("jnzs", this.parseArray(obj.getJSONArray("技能证书"))); - } - - if (obj.containsKey("校园经历")) { - rs.put("xyjl", this.parseArray(obj.getJSONArray("校园经历"))); - } - - if (obj.containsKey("工作信息")) { - rs.put("gzxg", obj.getJSONArray("工作信息").toJSONString()); - } - - if (obj.containsKey("期望从事岗位")) { - rs.put("qwcsgw", this.parseArray(obj.getJSONArray("期望从事岗位"))); - } - - if (obj.containsKey("工作经验")) { - rs.put("gzjy1", this.parseArray(obj.getJSONArray("工作经验"))); - } - - if (obj.containsKey("期望薪资")) { - rs.put("qwxz", this.parseArray(obj.getJSONArray("期望薪资"))); - } - - if (obj.containsKey("期望工作地点")) { - rs.put("qwgzdd", this.parseArray(obj.getJSONArray("期望工作地点"))); - } - - if (obj.containsKey("项目经历")) { - rs.put("xmjl", this.parseArray(obj.getJSONArray("项目经历"))); - } - } - - rs.put("formmodeid", this.formmodeid_tmp); - rs.put("modedatacreater", "1"); - rs.put("modedatacreatertype", "0"); - rs.put("modedatacreatedate", DateUtil.today()); - rs.put("modedatacreatetime", DateUtil.formatTime(new Date())); - return rs; - } - - private String parseArray(JSONArray ar) { - String rs = ""; - if (ar != null && ar.size() > 0) { - for(int i = 0; i < ar.size(); ++i) { - if (i == ar.size() - 1) { - rs = rs + ar.get(i); - } else { - rs = rs + ar.get(i) + ","; - } - } - } - - return rs; - } -} diff --git a/src/com/engine/resumestorage/service/impl/ResumeStorageServiceImpl.java b/src/com/engine/resumestorage/service/impl/ResumeStorageServiceImpl.java deleted file mode 100644 index 7ae1e97..0000000 --- a/src/com/engine/resumestorage/service/impl/ResumeStorageServiceImpl.java +++ /dev/null @@ -1,305 +0,0 @@ -package com.engine.resumestorage.service.impl; - -import cn.hutool.core.date.DateUtil; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.engine.core.exception.ECException; -import com.engine.core.impl.Service; -import com.engine.resumestorage.service.ResumeStorageService; -import com.engine.resumestorage.util.ParseResumeUtil; -import com.engine.resumestorage.util.Sql; -import com.engine.resumestorage.web.ResumeStorageAction; -import org.apache.commons.lang3.StringUtils; -import weaver.conn.RecordSetTrans; -import weaver.formmode.setup.ModeRightInfo; -import weaver.general.BaseBean; -import weaver.general.Util; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -import java.util.*; - -public class ResumeStorageServiceImpl extends Service implements ResumeStorageService { - private final Logger log = LoggerFactory.getLogger(ResumeStorageAction.class); - BaseBean bb = new BaseBean(); - String formmodeid_tmp; - String sfsymr; - - public ResumeStorageServiceImpl() { - this.formmodeid_tmp = this.bb.getPropValue("youyun", "formmodeid"); - this.sfsymr = this.bb.getPropValue("youyun", "sfsymr"); - } - - public int saveResumeByImageFileId(int imageFileId) throws Exception { - String response = ParseResumeUtil.parse(imageFileId); - JSONObject all = JSONObject.parseObject(response); - String error_msg = all.getString("error_msg"); - if (!"成功".equals(error_msg)) { - return -1; - } else { - Map saveResume = this.genResumeSaveTemplate(); - JSONObject cv_parse = all.getJSONObject("data").getJSONObject("cv_parse"); - saveResume.putAll(this.buildBasicInfo(cv_parse.getJSONObject("basic_info"))); - this.log.info("error_msg111111"); - saveResume.putAll(this.buildEducations(this.getJsonArrayFirstIfPresent(cv_parse.getJSONArray("educations")))); - this.log.info("error_msg222"); - saveResume.putAll(this.buildContact(cv_parse.getJSONObject("contact"))); - this.log.info("error_msg33333"); - saveResume.putAll(this.buildJobObjective(cv_parse.getJSONObject("job_objective"))); - this.log.info("error_msg44444"); - saveResume.putAll(this.buildOccupations(this.getJsonArrayFirstIfPresent(cv_parse.getJSONArray("occupations")))); - this.log.info("error_msg5555"); - this.log.info("saveResume: " + JSON.toJSONString(saveResume)); - return this.saveResumeInDB(saveResume); - } - } - - public int saveResumeInDB(Map fields) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("youyun", "tablename"); - } - - RecordSetTrans rst = new RecordSetTrans(); - rst.setAutoCommit(false); - List field = new ArrayList(); - List value_zhanweifu = new ArrayList(); - List value = new ArrayList(); - fields.forEach((key, v) -> { - if (StringUtils.isNotEmpty(v)) { - field.add(key); - value.add(v); - value_zhanweifu.add("?"); - } - - }); - String sql = "insert into " + tablename + "(" + String.join(",", field) + ") values(" + String.join(",", value_zhanweifu) + ")"; - this.log.info(sql); - - try { - boolean flag = rst.executeUpdate(sql, new Object[]{value}); - this.log.info(flag); - rst.commit(); - if (flag) { - String idSql = "SELECT max(id) as mid from " + tablename; - this.log.info(idSql); - String id = Sql.querySingleField(idSql, "mid"); - this.permissionReconstruction(Util.getIntValue(id)); - return Integer.parseInt(id); - } else { - return -1; - } - } catch (Exception var11) { - rst.rollback(); - this.log.error(var11); - throw new ECException("简历更新失败"); - } - } - - private void permissionReconstruction(int billId) { - ModeRightInfo ModeRightInfo = new ModeRightInfo(); - ModeRightInfo.setNewRight(true); - ModeRightInfo.editModeDataShare(1, Util.getIntValue(this.formmodeid_tmp), billId); - } - - public Map queryByDBId(String resumeid) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("youyun", "tablename"); - } - - String sql = "select * from " + tablename + " where id=" + resumeid; - return Sql.querySingleRow(sql); - } - - public boolean deleteById(String resumeid) throws Exception { - String tablename = "uf_jg_rmk"; - if ("1".equals(this.sfsymr)) { - tablename = this.bb.getPropValue("youyun", "tablename"); - } - - String sql = "delete " + tablename + " where id=" + resumeid; - RecordSetTrans rst = new RecordSetTrans(); - rst.setAutoCommit(false); - - try { - rst.executeUpdate(sql, new Object[0]); - rst.commit(); - return true; - } catch (Exception var6) { - rst.rollback(); - throw new Exception(var6); - } - } - - private JSONObject getJsonArrayFirstIfPresent(JSONArray jsonArray) { - return jsonArray.size() > 0 ? jsonArray.getJSONObject(0) : null; - } - - private Map buildOccupations(JSONObject occupations) { - Map company = new HashMap(); - if (occupations == null) { - return company; - } else { - if (occupations.containsKey("company")) { - if ("1".equals(this.sfsymr)) { - company.put(this.bb.getPropValue("youyun", "gs"), Util.null2String(occupations.getString("expect_salary"))); - } else { - company.put("gs", Util.null2String(occupations.getString("expect_salary"))); - } - } - - return company; - } - } - - private Map buildJobObjective(JSONObject job_objective) { - Map expect_salary = new HashMap(); - if (job_objective == null) { - return expect_salary; - } else { - if (job_objective.containsKey("expect_salary")) { - if ("1".equals(this.sfsymr)) { - expect_salary.put(this.bb.getPropValue("youyun", "qwxz"), Util.null2String(job_objective.getString("expect_salary"))); - } else { - expect_salary.put("qwxz", Util.null2String(job_objective.getString("expect_salary"))); - } - } - - return expect_salary; - } - } - - private Map buildContact(JSONObject contact) { - Map mobile = new HashMap(); - if (contact.containsKey("mobile")) { - if ("1".equals(this.sfsymr)) { - mobile.put(this.bb.getPropValue("youyun", "wx"), Util.null2String(contact.getString("mobile"))); - mobile.put(this.bb.getPropValue("youyun", "sjhm"), Util.null2String(contact.getString("mobile"))); - mobile.put(this.bb.getPropValue("youyun", "qq"), Util.null2String(contact.getString("qq"))); - mobile.put(this.bb.getPropValue("youyun", "email"), Util.null2String(contact.getString("email"))); - } else { - mobile.put("wx", Util.null2String(contact.getString("mobile"))); - mobile.put("sjhm", Util.null2String(contact.getString("mobile"))); - mobile.put("qq", Util.null2String(contact.getString("qq"))); - mobile.put("email", Util.null2String(contact.getString("email"))); - } - } - - return mobile; - } - - private Map buildEducations(JSONObject educations) { - Map major = new HashMap(); - if (educations == null) { - return major; - } else { - if (educations.containsKey("major")) { - if ("1".equals(this.sfsymr)) { - major.put(this.bb.getPropValue("youyun", "sxzy"), Util.null2String(educations.getString("major"))); - } else { - major.put("sxzy", Util.null2String(educations.getString("major"))); - } - } - - return major; - } - } - - private Map buildBasicInfo(JSONObject basicInfo) { - Map basic = new HashMap(); - if (basicInfo.containsKey("name")) { - String jzd; - if ("1".equals(this.sfsymr)) { - basic.put(this.bb.getPropValue("youyun", "rmxm"), Util.null2String(basicInfo.getString("name"))); - basic.put(this.bb.getPropValue("youyun", "nl"), Util.null2String(basicInfo.getInteger("age"))); - if ("男".equals(Util.null2String(basicInfo.getString("gender")))) { - basic.put(this.bb.getPropValue("youyun", "xb"), "0"); - } else if ("女".equals(Util.null2String(basicInfo.getString("gender")))) { - basic.put(this.bb.getPropValue("youyun", "xb"), "1"); - } - - jzd = basicInfo.getJSONObject("location").getString("province") + basicInfo.getJSONObject("location").getString("city"); - basic.put(this.bb.getPropValue("youyun", "jzd"), Util.null2String(jzd)); - } else { - basic.put("rmxm", Util.null2String(basicInfo.getString("name"))); - basic.put("nl", Util.null2String(basicInfo.getInteger("age"))); - if ("男".equals(Util.null2String(basicInfo.getString("gender")))) { - basic.put("xb", "0"); - } else if ("女".equals(Util.null2String(basicInfo.getString("gender")))) { - basic.put("xb", "1"); - } - - jzd = basicInfo.getJSONObject("location").getString("province") + basicInfo.getJSONObject("location").getString("city"); - basic.put("jzd", Util.null2String(jzd)); - } - } - - return basic; - } - - private Map genResumeSaveTemplate() { - Map resumes = new HashMap(); - resumes.put("gxsj", ""); - resumes.put("gwppdnew", ""); - resumes.put("zhaopinh", ""); - resumes.put("xx", ""); - resumes.put("requesti", ""); - resumes.put("cz", ""); - resumes.put("ryid", ""); - resumes.put("gwckr", ""); - resumes.put("rcjl", ""); - resumes.put("xb", ""); - resumes.put("gzjy", ""); - resumes.put("msjl", ""); - resumes.put("msry", ""); - resumes.put("sfsc", ""); - resumes.put("rmxm", ""); - resumes.put("khjl", ""); - resumes.put("lyqd", ""); - resumes.put("sf", ""); - resumes.put("cs", ""); - resumes.put("sjhm", ""); - resumes.put("sjhm2", ""); - resumes.put("zj", ""); - resumes.put("email", ""); - resumes.put("email2", ""); - resumes.put("qq", ""); - resumes.put("wx", ""); - resumes.put("grjl", ""); - resumes.put("gs", ""); - resumes.put("ysry", ""); - resumes.put("rmjb", ""); - resumes.put("kgjxfx", ""); - resumes.put("rmldfx", ""); - resumes.put("rmbq", ""); - resumes.put("zmhyx", ""); - resumes.put("zmhsjchqk", ""); - resumes.put("bz", ""); - resumes.put("fjsc", ""); - resumes.put("jhmssj", ""); - resumes.put("sjmssj", ""); - resumes.put("msxs", ""); - resumes.put("msjg", ""); - resumes.put("jzd", ""); - resumes.put("zgxl", ""); - resumes.put("sxzy", ""); - resumes.put("drgw", ""); - resumes.put("bm", ""); - resumes.put("qszt", ""); - resumes.put("lxrq", ""); - resumes.put("ppgw_new", ""); - resumes.put("nl", ""); - resumes.put("qwxz", ""); - resumes.put("sfz", ""); - resumes.put("sfgz", ""); - resumes.put("jlfl", ""); - resumes.put("formmodeid", this.formmodeid_tmp); - resumes.put("modedatacreater", "1"); - resumes.put("modedatacreatertype", "0"); - resumes.put("modedatacreatedate", DateUtil.today()); - resumes.put("modedatacreatetime", DateUtil.formatTime(new Date())); - return resumes; - } -} diff --git a/src/com/engine/resumestorage/util/AjaxResult.java b/src/com/engine/resumestorage/util/AjaxResult.java deleted file mode 100644 index 2cde165..0000000 --- a/src/com/engine/resumestorage/util/AjaxResult.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.engine.resumestorage.util; - -import java.io.Serializable; - -public class AjaxResult implements Serializable { - private static final long serialVersionUID = -4302377008637324176L; - private long code; - private String message; - private T data; - - public long getCode() { - return this.code; - } - - public void setCode(long code) { - this.code = code; - } - - public String getMessage() { - return this.message; - } - - public void setMessage(String message) { - this.message = message; - } - - public T getData() { - return this.data; - } - - public void setData(T data) { - this.data = data; - } - - public AjaxResult() { - } - - public AjaxResult(long code, String message, T data) { - this.code = code; - this.message = message; - this.data = data; - } - - public static AjaxResult ok(T data) { - return new AjaxResult(200L, "", data); - } - - public static AjaxResult ok(T data, String message) { - return new AjaxResult(200L, message, data); - } - - public static AjaxResult failed() { - return new AjaxResult(400L, "fail", (Object)null); - } - - public static AjaxResult error() { - return new AjaxResult(500L, "error", (Object)null); - } - - public static AjaxResult failed(String message) { - return new AjaxResult(400L, message, (Object)null); - } - - public static AjaxResult error(String message) { - return new AjaxResult(500L, message, (Object)null); - } - - public String toString() { - return "AjaxResult{code=" + this.code + ", message='" + this.message + '\'' + ", data=" + this.data + '}'; - } -} diff --git a/src/com/engine/resumestorage/util/Assert.java b/src/com/engine/resumestorage/util/Assert.java deleted file mode 100644 index 5d91e1f..0000000 --- a/src/com/engine/resumestorage/util/Assert.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.engine.resumestorage.util; - -import java.util.List; -import java.util.Map; - -public final class Assert { - public Assert() { - } - - public static boolean isEmpty(Object obj) { - if (obj == null) { - return true; - } else if (obj instanceof String) { - return ((String)obj).trim().equals(""); - } else if (obj instanceof List) { - return ((List)obj).isEmpty(); - } else { - return obj instanceof Map ? ((Map)obj).isEmpty() : false; - } - } - - public static void isEmpty(Object obj, String msg) { - isTrue(isEmpty(obj), msg); - } - - public static boolean notEmpty(Object obj) { - return !isEmpty(obj); - } - - public static void notEmpty(Object obj, String msg) { - isTrue(notEmpty(obj), msg); - } - - public static void isTrue(Boolean flag, String msg) { - if (flag) { - throw new IllegalArgumentException(msg); - } - } -} diff --git a/src/com/engine/resumestorage/util/HttpUtils.java b/src/com/engine/resumestorage/util/HttpUtils.java deleted file mode 100644 index f694797..0000000 --- a/src/com/engine/resumestorage/util/HttpUtils.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.engine.resumestorage.util; - -import org.apache.commons.lang.StringUtils; -import org.apache.http.HttpResponse; -import org.apache.http.NameValuePair; -import org.apache.http.client.HttpClient; -import org.apache.http.client.entity.UrlEncodedFormEntity; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.conn.ClientConnectionManager; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.scheme.SchemeRegistry; -import org.apache.http.conn.ssl.SSLSocketFactory; -import org.apache.http.entity.ByteArrayEntity; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.message.BasicNameValuePair; - -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class HttpUtils { - /** - * get - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @return - * @throws Exception - */ - public static HttpResponse doGet(String host, String path, String method, - Map headers, - Map querys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpGet request = new HttpGet(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - return httpClient.execute(request); - } - - /** - * post form - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param bodys - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - Map bodys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (bodys != null) { - List nameValuePairList = new ArrayList(); - - for (String key : bodys.keySet()) { - nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); - } - UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); - formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); - request.setEntity(formEntity); - } - - return httpClient.execute(request); - } - - /** - * Post String - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - String body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (StringUtils.isNotBlank(body)) { - request.setEntity(new StringEntity(body, "utf-8")); - } - - return httpClient.execute(request); - } - - /** - * Post stream - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPost(String host, String path, String method, - Map headers, - Map querys, - byte[] body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPost request = new HttpPost(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (body != null) { - request.setEntity(new ByteArrayEntity(body)); - } - - return httpClient.execute(request); - } - - /** - * Put String - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPut(String host, String path, String method, - Map headers, - Map querys, - String body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPut request = new HttpPut(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (StringUtils.isNotBlank(body)) { - request.setEntity(new StringEntity(body, "utf-8")); - } - - return httpClient.execute(request); - } - - /** - * Put stream - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @param body - * @return - * @throws Exception - */ - public static HttpResponse doPut(String host, String path, String method, - Map headers, - Map querys, - byte[] body) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpPut request = new HttpPut(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - if (body != null) { - request.setEntity(new ByteArrayEntity(body)); - } - - return httpClient.execute(request); - } - - /** - * Delete - * - * @param host - * @param path - * @param method - * @param headers - * @param querys - * @return - * @throws Exception - */ - public static HttpResponse doDelete(String host, String path, String method, - Map headers, - Map querys) - throws Exception { - HttpClient httpClient = wrapClient(host); - - HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); - for (Map.Entry e : headers.entrySet()) { - request.addHeader(e.getKey(), e.getValue()); - } - - return httpClient.execute(request); - } - - private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException { - StringBuilder sbUrl = new StringBuilder(); - sbUrl.append(host); - if (!StringUtils.isBlank(path)) { - sbUrl.append(path); - } - if (null != querys) { - StringBuilder sbQuery = new StringBuilder(); - for (Map.Entry query : querys.entrySet()) { - if (0 < sbQuery.length()) { - sbQuery.append("&"); - } - if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { - sbQuery.append(query.getValue()); - } - if (!StringUtils.isBlank(query.getKey())) { - sbQuery.append(query.getKey()); - if (!StringUtils.isBlank(query.getValue())) { - sbQuery.append("="); - sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); - } - } - } - if (0 < sbQuery.length()) { - sbUrl.append("?").append(sbQuery); - } - } - - return sbUrl.toString(); - } - - private static HttpClient wrapClient(String host) { - HttpClient httpClient = new DefaultHttpClient(); - if (host.startsWith("https://")) { - sslClient(httpClient); - } - - return httpClient; - } - - private static void sslClient(HttpClient httpClient) { - try { - SSLContext ctx = SSLContext.getInstance("TLS"); - X509TrustManager tm = new X509TrustManager() { - public X509Certificate[] getAcceptedIssuers() { - return null; - } - public void checkClientTrusted(X509Certificate[] xcs, String str) { - - } - public void checkServerTrusted(X509Certificate[] xcs, String str) { - - } - }; - ctx.init(null, new TrustManager[] { tm }, null); - SSLSocketFactory ssf = new SSLSocketFactory(ctx); - ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); - ClientConnectionManager ccm = httpClient.getConnectionManager(); - SchemeRegistry registry = ccm.getSchemeRegistry(); - registry.register(new Scheme("https", 443, ssf)); - } catch (KeyManagementException ex) { - throw new RuntimeException(ex); - } catch (NoSuchAlgorithmException ex) { - throw new RuntimeException(ex); - } - } -} - diff --git a/src/com/engine/resumestorage/util/ParseResumeQliUtil.java b/src/com/engine/resumestorage/util/ParseResumeQliUtil.java deleted file mode 100644 index 0c08a97..0000000 --- a/src/com/engine/resumestorage/util/ParseResumeQliUtil.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.engine.resumestorage.util; - -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.mime.MultipartEntityBuilder; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import weaver.file.ImageFileManager; -import weaver.general.BaseBean; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -import java.io.IOException; -import java.math.BigInteger; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public final class ParseResumeQliUtil { - private static final BaseBean bb = new BaseBean(); - private static final Logger log = LoggerFactory.getLogger(ParseResumeQliUtil.class); - private static final String url; - private static final String appId; - private static final String appSecret; - - public ParseResumeQliUtil() { - } - - public static String doParseHostPost(int imageFileId) { - long currentTime = System.currentTimeMillis(); - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(imageFileId); - HttpPost postRequest = new HttpPost(url); - postRequest.addHeader("sign", getSign(appId, appSecret, currentTime)); - postRequest.addHeader("appId", appId); - postRequest.addHeader("timestamp", String.valueOf(currentTime)); - MultipartEntityBuilder builder = MultipartEntityBuilder.create(); - builder.addTextBody("type", "pdf"); - builder.addBinaryBody("resume", manager.getInputStream(), ContentType.APPLICATION_OCTET_STREAM, manager.getImageFileName()); - HttpEntity entity = builder.build(); - postRequest.setEntity(entity); - CloseableHttpClient httpClient = HttpClients.createDefault(); - CloseableHttpResponse response = null; - String responseBody = ""; - - try { - response = httpClient.execute(postRequest); - HttpEntity responseEntity = response.getEntity(); - responseBody = EntityUtils.toString(responseEntity); - return responseBody; - } catch (IOException var11) { - throw new RuntimeException(var11); - } - } - - private static String getSign(String appId, String appSecret, long timestamp) { - if (appId != null && appId.length() != 0) { - if (appSecret != null && appSecret.length() != 0) { - try { - MessageDigest MD5 = MessageDigest.getInstance("MD5"); - MD5.update(appId.getBytes()); - MD5.update((timestamp + "").getBytes()); - MD5.update(appSecret.getBytes()); - byte[] bytes = MD5.digest(); - String hex = (new BigInteger(1, bytes)).toString(16); - - for(int fix0 = bytes.length * 2 - hex.length(); fix0-- > 0; hex = "0" + hex) { - } - - return hex; - } catch (NoSuchAlgorithmException var8) { - throw new RuntimeException("不支持的加密算法", var8); - } - } else { - throw new RuntimeException("appSecret不能为空"); - } - } else { - throw new RuntimeException("appId不能为空"); - } - } - - static { - url = bb.getPropValue("resume_qianliling", "qianlilingurl"); - appId = bb.getPropValue("resume_qianliling", "appId"); - appSecret = bb.getPropValue("resume_qianliling", "appSecret"); - } -} diff --git a/src/com/engine/resumestorage/util/ParseResumeUtil.java b/src/com/engine/resumestorage/util/ParseResumeUtil.java deleted file mode 100644 index bc64a22..0000000 --- a/src/com/engine/resumestorage/util/ParseResumeUtil.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.engine.resumestorage.util; - -import com.engine.core.exception.ECException; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.io.FileUtils; -import org.apache.http.HttpResponse; -import org.apache.http.util.EntityUtils; -import weaver.file.ImageFileManager; -import weaver.general.BaseBean; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -public final class ParseResumeUtil { - private static final BaseBean bb = new BaseBean(); - private static final Logger log = LoggerFactory.getLogger(ParseResumeUtil.class); - private static String PARSE_HOST; - private static String PATH; - private static String METHOD; - private static String APPCODE; - - public ParseResumeUtil() { - } - - private static String doParseHostPost(int imageFileId) throws Exception { - bb.writeLog("PARSE_HOST=" + PARSE_HOST); - bb.writeLog("PATH=" + PATH); - bb.writeLog("METHOD=" + METHOD); - bb.writeLog("APPCODE=" + APPCODE); - ImageFileManager manager = new ImageFileManager(); - manager.getImageFileInfoById(imageFileId); - String filePath = manager.getFileRealPath(); - File file = new File(filePath); - Map headers = new HashMap(); - headers.put("Authorization", "APPCODE " + APPCODE); - headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); - Map querys = new HashMap(); - Map bodys = new HashMap(); - byte[] bytes = FileUtils.readFileToByteArray(file); - String base64 = Base64.encodeBase64String(bytes); - bodys.put("content", base64); - bodys.put("ext", "doc"); - - try { - HttpResponse response = HttpUtils.doPost(PARSE_HOST, PATH, METHOD, headers, querys, bodys); - return EntityUtils.toString(response.getEntity()); - } catch (Exception var10) { - throw new ECException("简历解析失败!详情:" + var10.getMessage()); - } - } - - public static String parse(int imageFileId) { - try { - log.info("简历imageFileId:" + imageFileId); - log.info("doParseHostPost start.."); - String response = doParseHostPost(imageFileId); - log.info("end.. \n" + response); - return response; - } catch (Exception var2) { - log.error("catch error: " + var2.getMessage()); - return ""; - } - } - - static { - PARSE_HOST = bb.getPropValue("youyun", "host"); - PATH = bb.getPropValue("youyun", "path"); - METHOD = bb.getPropValue("youyun", "method"); - APPCODE = bb.getPropValue("youyun", "appcode"); - } -} diff --git a/src/com/engine/resumestorage/util/Sql.java b/src/com/engine/resumestorage/util/Sql.java deleted file mode 100644 index 26c864f..0000000 --- a/src/com/engine/resumestorage/util/Sql.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.engine.resumestorage.util; - -import weaver.conn.RecordSet; -import weaver.general.Util; - -import java.util.*; - -public final class Sql { - public Sql() { - } - - public static String querySingleField(String sql) { - Assert.isEmpty(sql, "sql"); - RecordSet rs = new RecordSet(); - rs.execute(sql); - rs.next(); - return rs.getString(1); - } - - public static String querySingleField(String sql, String field) { - Assert.isEmpty(sql, "execute sql"); - Assert.isEmpty(sql, "field"); - RecordSet rs = new RecordSet(); - rs.execute(sql); - rs.next(); - return Util.null2String(rs.getString(field)); - } - - public static String querySingleFieldWithPlaceholder(String sql, String field, Object... params) { - Assert.isEmpty(sql, "execute sql"); - Assert.isEmpty(sql, "field"); - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, params); - rs.next(); - return Util.null2String(rs.getString(field)); - } - - public static Map querySingleRow(String sql) { - Assert.isEmpty(sql, "sql"); - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, new Object[0]); - rs.next(); - return mapFromRecordRow(rs); - } - - public static Map querySingleRow(String sql, Object... params) { - Assert.isEmpty(sql, "sql null"); - RecordSet rs = new RecordSet(); - rs.executeQuery(sql, params); - rs.next(); - return mapFromRecordRow(rs); - } - - private static Map mapFromRecordRow(RecordSet rs) { - Assert.isEmpty(rs, "RecordSet"); - String[] cols = rs.getColumnName(); - Map result = new HashMap(cols.length + (cols.length >> 1)); - String[] var3 = cols; - int var4 = cols.length; - - for(int var5 = 0; var5 < var4; ++var5) { - String key = var3[var5]; - if (key != null && !key.equals("")) { - String value = Util.null2String(rs.getString(key)); - result.put(key.toLowerCase(), value); - } - } - - return result; - } - - public static List> query(String table, String fields, String... conditions) { - Assert.isEmpty(table); - if (fields == null || fields.equals("")) { - fields = "*"; - } - - StringBuilder builder = null; - if (conditions != null && conditions.length > 0) { - builder = new StringBuilder(" where "); - - for(int i = 0; i < conditions.length; ++i) { - if (i > 0) { - builder.append(" and "); - } - - builder.append(conditions[i]); - } - } - - return query("select " + fields + " from " + table + (builder == null ? "" : builder.toString())); - } - - public static List> queryWithPlaceholder(String table, String fields, String conditions, Object... params) { - Assert.isEmpty(table); - if (fields == null || fields.equals("")) { - fields = "*"; - } - - StringBuilder builder = null; - List conditionList = Arrays.asList(conditions.split(",")); - if (Assert.notEmpty(conditionList)) { - builder = new StringBuilder(" where "); - - for(int i = 0; i < conditionList.size(); ++i) { - if (i > 0) { - builder.append(" and "); - } - - builder.append((String)conditionList.get(i)).append("=?"); - } - } - - return queryWithPlaceholder("select " + fields + " from " + table + (builder == null ? "" : builder.toString()), params); - } - - public static List> query(String sql) { - RecordSet rs = new RecordSet(); - rs.execute(sql); - return query(rs); - } - - public static List> queryWithOrder(String sql) { - RecordSet rs = new RecordSet(); - rs.execute(sql); - return query(rs); - } - - public static List> queryWithPlaceholder(String sql, Object... conditions) { - RecordSet rs = new RecordSet(); - if (conditions != null && conditions.length > 0) { - rs.executeQuery(sql, conditions); - } else { - rs.executeQuery(sql, new Object[0]); - } - - return query(rs); - } - - public static List> query(RecordSet rs) { - List> result = new ArrayList(); - - while(rs.next()) { - result.add(mapFromRecordRow(rs)); - } - - return result; - } -} diff --git a/src/com/engine/resumestorage/web/ResumeIdentifyQliAction.java b/src/com/engine/resumestorage/web/ResumeIdentifyQliAction.java deleted file mode 100644 index a42da9e..0000000 --- a/src/com/engine/resumestorage/web/ResumeIdentifyQliAction.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.engine.resumestorage.web; - -import com.engine.common.util.ParamUtil; -import com.engine.common.util.ServiceUtil; -import com.engine.resumestorage.service.ResumeIdentifyService; -import com.engine.resumestorage.service.impl.ResumeIdentifyServiceImpl; -import com.engine.resumestorage.util.AjaxResult; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import java.util.Map; - -public class ResumeIdentifyQliAction { - private final Logger log = LoggerFactory.getLogger(ResumeIdentifyQliAction.class); - - public ResumeIdentifyQliAction() { - } - - private ResumeIdentifyService getService() { - return (ResumeIdentifyService)ServiceUtil.getService(ResumeIdentifyServiceImpl.class); - } - - @POST - @Path("/upload") - @Produces({"application/json"}) - public AjaxResult upload(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String imageFileId = (String)map.get("imageFileId"); - - try { - return AjaxResult.ok(this.getService().saveResumeByImageFileId(Integer.parseInt(imageFileId))); - } catch (Exception var5) { - this.log.error("千里零...简历上传解析失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } - - @GET - @Path("/queryById") - @Produces({"application/json"}) - public AjaxResult> queryById(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String resumeid = (String)map.get("resumeid"); - - try { - return AjaxResult.ok(this.getService().queryByDBId(resumeid)); - } catch (Exception var5) { - this.log.error("简历查询失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } - - @GET - @Path("/deleteById") - @Produces({"application/json"}) - public AjaxResult deleteById(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String resumeid = (String)map.get("resumeid"); - - try { - return AjaxResult.ok(this.getService().deleteById(resumeid)); - } catch (Exception var5) { - this.log.error("简历删除失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } -} diff --git a/src/com/engine/resumestorage/web/ResumeStorageAction.java b/src/com/engine/resumestorage/web/ResumeStorageAction.java deleted file mode 100644 index c1493b2..0000000 --- a/src/com/engine/resumestorage/web/ResumeStorageAction.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.engine.resumestorage.web; - -import com.engine.common.util.ParamUtil; -import com.engine.common.util.ServiceUtil; -import com.engine.resumestorage.service.ResumeStorageService; -import com.engine.resumestorage.service.impl.ResumeStorageServiceImpl; -import com.engine.resumestorage.util.AjaxResult; -import weaver.integration.logging.Logger; -import weaver.integration.logging.LoggerFactory; - -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import java.util.Map; - -public class ResumeStorageAction { - private final Logger log = LoggerFactory.getLogger(ResumeStorageAction.class); - - public ResumeStorageAction() { - } - - private ResumeStorageService getService() { - return (ResumeStorageService)ServiceUtil.getService(ResumeStorageServiceImpl.class); - } - - @POST - @Path("/upload") - @Produces({"application/json"}) - public AjaxResult upload(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String imageFileId = (String)map.get("imageFileId"); - - try { - return AjaxResult.ok(this.getService().saveResumeByImageFileId(Integer.parseInt(imageFileId))); - } catch (Exception var5) { - this.log.error("简历上传解析失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } - - @GET - @Path("/queryById") - @Produces({"application/json"}) - public AjaxResult> queryById(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String resumeid = (String)map.get("resumeid"); - - try { - return AjaxResult.ok(this.getService().queryByDBId(resumeid)); - } catch (Exception var5) { - this.log.error("简历查询失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } - - @GET - @Path("/deleteById") - @Produces({"application/json"}) - public AjaxResult deleteById(@Context HttpServletRequest request) { - Map map = ParamUtil.request2Map(request); - String resumeid = (String)map.get("resumeid"); - - try { - return AjaxResult.ok(this.getService().deleteById(resumeid)); - } catch (Exception var5) { - this.log.error("简历删除失败!详情:\n" + var5.getMessage()); - return AjaxResult.error(var5.getMessage()); - } - } -} diff --git a/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java b/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java index 500312f..8093e75 100644 --- a/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java +++ b/src/weaver/formmode/recruit/modeexpand/util/RecruitModeUtil.java @@ -37,7 +37,14 @@ import java.util.regex.Pattern; public class RecruitModeUtil { private static final Pattern MSG_PATTERN = Pattern.compile(Pattern.quote("{") + "(.*?)" + Pattern.quote("}")); + /** + * 服务外网映射地址 + */ public static final String HTTP_URL = getRecruitPropValue("HTTP_URL"); + /** + * 简历识别服务类 + */ + public static final String OCR_TYPE = getRecruitPropValue("OCR_TYPE"); /** * 消息推送 @@ -147,9 +154,9 @@ public class RecruitModeUtil { return FormInfoManager.getInstance().getAllField(formId); } - public static String getFieldShowName(Formfield formfield, String fieldName) { + public static String getFieldShowName(Formfield formfield, String fieldValue) { User user = new User(1); - return FieldHandler.getFieldValue(fieldName, formfield, true, user); + return FieldHandler.getFieldValue(fieldValue, formfield, true, user); } public static String getReplaceContent(String content, Map> fieldMapList, Map paramsData) {