123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467 |
- package com.kingdee.shr.recuritment.service.smartimport;
- import java.io.IOException;
- import java.io.UnsupportedEncodingException;
- import java.text.SimpleDateFormat;
- import java.util.Arrays;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
- import java.util.Map;
- import java.util.concurrent.BlockingQueue;
- import java.util.concurrent.Future;
- import java.util.concurrent.LinkedBlockingQueue;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.log4j.Logger;
- import org.springframework.web.multipart.MultipartFile;
- import com.kingdee.bos.BOSException;
- import com.kingdee.bos.Context;
- import com.kingdee.bos.dao.IObjectPK;
- import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
- import com.kingdee.bos.metadata.data.SortType;
- import com.kingdee.bos.metadata.entity.EntityViewInfo;
- import com.kingdee.bos.metadata.entity.FilterInfo;
- import com.kingdee.bos.metadata.entity.FilterItemInfo;
- import com.kingdee.bos.metadata.entity.SelectorItemCollection;
- import com.kingdee.bos.metadata.entity.SelectorItemInfo;
- import com.kingdee.bos.metadata.entity.SorterItemCollection;
- import com.kingdee.bos.metadata.entity.SorterItemInfo;
- import com.kingdee.bos.metadata.query.util.CompareType;
- import com.kingdee.bos.util.BOSUuid;
- import com.kingdee.eas.base.permission.UserInfo;
- import com.kingdee.eas.basedata.person.PersonInfo;
- import com.kingdee.eas.common.EASBizException;
- import com.kingdee.eas.util.app.ContextUtil;
- import com.kingdee.eas.util.app.DbUtil;
- import com.kingdee.shr.base.syssetting.context.SHRContext;
- import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
- import com.kingdee.shr.recuritment.ISmartImportTask;
- import com.kingdee.shr.recuritment.RecuritmentDemandInfo;
- import com.kingdee.shr.recuritment.ResumeClipBaseInfo;
- import com.kingdee.shr.recuritment.ResumeSourceInfo;
- import com.kingdee.shr.recuritment.ResumeSourceType;
- import com.kingdee.shr.recuritment.SmartImportTaskCollection;
- import com.kingdee.shr.recuritment.SmartImportTaskDetailCollection;
- import com.kingdee.shr.recuritment.SmartImportTaskDetailFactory;
- import com.kingdee.shr.recuritment.SmartImportTaskDetailInfo;
- import com.kingdee.shr.recuritment.SmartImportTaskFactory;
- import com.kingdee.shr.recuritment.SmartImportTaskInfo;
- import com.kingdee.shr.recuritment.TaskStateEnum;
- import com.kingdee.shr.recuritment.TaskTypeEnum;
- import com.kingdee.shr.recuritment.app.util.EncodingDetect;
- import com.kingdee.shr.recuritment.app.util.db.RecDBUtils;
- import com.kingdee.shr.recuritment.app.util.job.RecSyncTaskThreadPool;
- import com.kingdee.shr.recuritment.service.smartimport.base.impl.ArchiveSmartImportImpl;
- import com.kingdee.shr.recuritment.service.smartimport.base.impl.RecommendResumeSmartImportImpl;
- import com.kingdee.shr.recuritment.service.smartimport.base.impl.ResumeSmartImportImpl;
- import com.kingdee.shr.recuritment.service.smartimport.entity.SmartImportTaskEntity;
- import com.kingdee.shr.recuritment.util.FileSafeUtil;
- import com.kingdee.shr.recuritment.util.RecWebBaseUtils;
- import com.kingdee.shr.recuritment.util.XSSDefenseUtil;
- import com.kingdee.shr.recuritment.util.vo.smartimport.SmartImportTask;
- import com.kingdee.shr.recuritment.utils.RecBaseUtils;
- public class SmartImportServiceEx {
- private static final Logger logger = Logger.getLogger(SmartImportServiceEx.class);
- private long taskTimeoutMillis;
- private final BlockingQueue<FutureTimeTask> futureTaskQueue;
- private static final List<Object> FILETYPELIST = Arrays.asList("DOC", "DOCX", "TXT", "RTF", "PDF", "MSG", "WPS",
- "JPG", "PNG", "GIF");
- private static final String FILETYPESTR = "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF";
- private int resumeFileMinSize;
- private int resumeFileMaxSize;
- private SmartImportServiceEx() {
- this.taskTimeoutMillis = 1800000L;
- this.resumeFileMinSize = 1;
- this.resumeFileMaxSize = 20971520;
- this.futureTaskQueue = new LinkedBlockingQueue();
- RecSyncTaskThreadPool.getInstance().submitAsyncTask(new TimeoutTaskCheckThread());
- }
- public static SmartImportServiceEx getInstance() throws ShrWebBizException {
- return SmartImportServiceEx.SmartImportServiceHolder.service;
- }
- public void setSmartImportChooseDemand(String recuritmentDemandId) throws ShrWebBizException {
- this.setSmartImportChooseDemand(recuritmentDemandId, TaskTypeEnum.SMARTIMPORT_RESUME);
- }
- public void setSmartImportChooseDemand(String recuritmentDemandId, TaskTypeEnum typeEnum)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(typeEnum);
- if (taskInfo != null) {
- try {
- IObjectPK recuritmentDemandPK = recuritmentDemandId == null ? null
- : new ObjectUuidPK(recuritmentDemandId);
- SmartImportTaskFactory.getRemoteInstance()
- .setSmartImportChooseDemand(new ObjectUuidPK(taskInfo.getId().toString()), recuritmentDemandPK);
- } catch (BOSException var5) {
- logger.error("******************设置智能导入所选需求失败!*****************");
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- public void setSmartImportChooseResumeClip(String resumeClipId, TaskTypeEnum taskType) throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
- if (taskInfo != null) {
- try {
- IObjectPK resumeClipPK = resumeClipId == null ? null : new ObjectUuidPK(resumeClipId);
- SmartImportTaskFactory.getRemoteInstance()
- .setSmartImportChooseResumeClip(new ObjectUuidPK(taskInfo.getId().toString()), resumeClipPK);
- } catch (BOSException var5) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- public void setSmartImportChooseRecommendation(String interRecommendation, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
- if (taskInfo != null) {
- try {
- IObjectPK interRecommendationId = interRecommendation == null ? null
- : new ObjectUuidPK(interRecommendation);
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
- new ObjectUuidPK(taskInfo.getId().toString()), interRecommendationId);
- } catch (BOSException var5) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- public void setSmartImportChooseResumeSource(String resumeSource, TaskTypeEnum taskType) throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
- if (taskInfo != null) {
- try {
- IObjectPK resumeSourceId = resumeSource == null ? null : new ObjectUuidPK(resumeSource);
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
- new ObjectUuidPK(taskInfo.getId().toString()), resumeSourceId);
- } catch (BOSException var5) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- public void setSmartImportChooseSourceType(String sourceType, TaskTypeEnum taskType) throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
- if (taskInfo != null) {
- try {
- SmartImportTaskFactory.getRemoteInstance()
- .setSmartImportChooseSourceType(new ObjectUuidPK(taskInfo.getId().toString()), sourceType);
- } catch (BOSException var5) {
- logger.error("******************设置智能导入所选来源类型失败!*****************");
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- /** @deprecated */
- @Deprecated
- public SmartImportTask uploadResume(Map<String, MultipartFile> fileMap, String taskId, String recuritmentDemandId)
- throws ShrWebBizException {
- SmartImportTask taskData = this.doUploadResume(fileMap, TaskTypeEnum.SMARTIMPORT_RESUME);
- return taskData;
- }
- /** @deprecated */
- @Deprecated
- public SmartImportTask uploadArchiveResume(Map<String, MultipartFile> fileMap, String taskId, String resumeClipId)
- throws ShrWebBizException {
- SmartImportTask taskData = this.doUploadResume(fileMap, TaskTypeEnum.SMARTIMPORT_ARCHIVE);
- return taskData;
- }
- public SmartImportTask uploadResume(Map<String, MultipartFile> fileMap, TaskTypeEnum type)
- throws ShrWebBizException {
- SmartImportTask taskData = this.doUploadResume(fileMap, type);
- return taskData;
- }
- private SmartImportTask doUploadResume(Map<String, MultipartFile> fileMap, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = null;
- SmartImportTaskDetailCollection detailColl = new SmartImportTaskDetailCollection();
- Context ctx = SHRContext.getInstance().getContext();
- Iterator var6 = fileMap.entrySet().iterator();
- while (true) {
- if (var6.hasNext()) {
- Map.Entry<String, MultipartFile> entity = (Map.Entry) var6.next();
- MultipartFile mf = (MultipartFile) entity.getValue();
- String resumeFileName = mf.getOriginalFilename();
- byte[] resumeFileData = null;
- try {
- resumeFileData = mf.getBytes();
- } catch (IOException var16) {
- logger.error(var16.getMessage(), var16);
- throw new ShrWebBizException("附件上传失败,获取附件内容异常!");
- }
- if (StringUtils.isBlank(resumeFileName)) {
- throw new ShrWebBizException("简历附件名不能为空:" + resumeFileName);
- }
- if (resumeFileData != null && resumeFileData.length >= this.resumeFileMinSize) {
- if (resumeFileData.length > this.resumeFileMaxSize) {
- throw new ShrWebBizException("简历附件大小不能超过:" + this.resumeFileMaxSize / 1024 / 1024 + "M!");
- }
- resumeFileData = FileSafeUtil.checkFileComplianceIncloudXSS(ctx, mf, FILETYPELIST,
- "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF");
- if (taskInfo == null) {
- taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
- }
- if (taskInfo == null) {
- if (logger.isDebugEnabled()) {
- logger.debug("上传简历失败,上传简历时获取任务失败");
- }
- throw new ShrWebBizException("上传简历失败。");
- }
- String fileType = resumeFileName.substring(resumeFileName.lastIndexOf(".") + 1);
- if (!StringUtils.equalsIgnoreCase("xls", fileType)
- && !StringUtils.equalsIgnoreCase("xlsx", fileType) && !resumeFileName.contains("csv")) {
- String encode;
- if (StringUtils.equals("text/html", fileType) || resumeFileName.contains("html")) {
- encode = EncodingDetect.getJavaEncode(resumeFileData);
- try {
- resumeFileData = XSSDefenseUtil.cleanXSS(new String(resumeFileData, encode))
- .getBytes(encode);
- } catch (UnsupportedEncodingException var15) {
- logger.error(var15.getMessage(), var15);
- throw new ShrWebBizException("上传简历失败。");
- }
- }
- encode = null;
- SmartImportTaskDetailInfo taskDetailInfo;
- try {
- taskDetailInfo = SmartImportTaskDetailFactory.getRemoteInstance()
- .addUploadResumeFile(resumeFileName, resumeFileData, taskInfo);
- } catch (BOSException var14) {
- logger.error("上传简历失败" + var14.getMessage());
- logger.error(var14.getMessage(), var14);
- throw new ShrWebBizException("上传简历失败。");
- }
- if (taskDetailInfo != null) {
- detailColl.add(taskDetailInfo);
- }
- continue;
- }
- throw new ShrWebBizException("非法文件!");
- }
- throw new ShrWebBizException("简历附件不能为空!");
- }
- if (taskInfo != null) {
- taskInfo.put("detailColl", detailColl);
- }
- return this.getSmartImportTaskSchedule(taskInfo);
- }
- }
- private synchronized SmartImportTaskInfo getUserProgressTaskOrAddNotExists(TaskTypeEnum taskType)
- throws ShrWebBizException {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- SmartImportTaskInfo taskInfo = this.getUserProgressSmartImportTask(user, taskType);
- if (taskInfo == null) {
- taskInfo = this.addUserProgressTask(user, taskType);
- }
- return taskInfo;
- }
- private SmartImportTaskInfo getUserProgressSmartImportTask(UserInfo user, TaskTypeEnum taskType)
- throws ShrWebBizException {
- try {
- SmartImportTaskInfo taskInfo = SmartImportTaskFactory.getRemoteInstance()
- .getUserProgressTask(new ObjectUuidPK(user.getId()), taskType);
- return taskInfo;
- } catch (BOSException var4) {
- logger.error(var4.getMessage(), var4);
- throw new ShrWebBizException("获取解析任务失败!");
- }
- }
- private SmartImportTaskInfo getSmartImportTaskById(String taskId) throws ShrWebBizException {
- try {
- SmartImportTaskInfo taskInfo = SmartImportTaskFactory.getRemoteInstance()
- .getSmartImportTaskInfo(new ObjectUuidPK(taskId));
- return taskInfo;
- } catch (EASBizException var3) {
- logger.error(var3.getMessage(), var3);
- throw new ShrWebBizException("获取解析任务失败!");
- } catch (BOSException var4) {
- logger.error(var4.getMessage(), var4);
- throw new ShrWebBizException("获取解析任务失败!");
- }
- }
- private SmartImportTaskInfo addUserProgressTask(UserInfo user, TaskTypeEnum taskType) throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = null;
- try {
- taskInfo = SmartImportTaskFactory.getRemoteInstance().addUserProgressTask(user, taskType);
- return taskInfo;
- } catch (BOSException var5) {
- logger.error(var5.getMessage(), var5);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- /** @deprecated */
- @Deprecated
- public void resumeSmartImport(String recuritmentDemandId, String taskId) throws ShrWebBizException {
- if (StringUtils.isBlank(recuritmentDemandId)) {
- throw new ShrWebBizException("请选择招聘需求!");
- } else if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- logger.debug("recuritmentDemandId = " + recuritmentDemandId + ",taskId=" + taskId);
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
- TaskTypeEnum.SMARTIMPORT_RESUME);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
- if (task == null) {
- throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
- } else {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
- new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
- RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
- recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- task.setRecDemand(recDemandInfo);
- } catch (BOSException var9) {
- logger.error("******************设置智能导入所选需求失败!*****************");
- logger.error(var9.getMessage(), var9);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- try {
- SmartImportTaskEntity entity = new SmartImportTaskEntity(task,
- new ResumeSmartImportImpl(recuritmentDemandId));
- this.submitTask(entity);
- } catch (BOSException var8) {
- logger.error(var8.getMessage(), var8);
- throw new ShrWebBizException();
- }
- }
- }
- }
- }
- /** @deprecated */
- @Deprecated
- public SmartImportTask resumeSmartImportAgain(String taskId) throws ShrWebBizException {
- if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
- TaskTypeEnum.SMARTIMPORT_RESUME);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo taskInfo = null;
- try {
- taskInfo = SmartImportTaskFactory.getRemoteInstance().getSmartImportTaskSchedule(
- new ObjectUuidPK(user.getId()), TaskTypeEnum.SMARTIMPORT_RESUME, taskId);
- } catch (BOSException var18) {
- logger.error(var18.getMessage(), var18);
- throw new ShrWebBizException("获取解析任务失败!");
- }
- String recuritmentDemandId = taskInfo.getRecDemand().getId().toString();
- SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, TaskTypeEnum.SMARTIMPORT_RESUME);
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
- new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
- RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
- recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- newTaskInfo.setRecDemand(recDemandInfo);
- } catch (BOSException var17) {
- logger.error("******************设置智能导入所选需求失败!*****************");
- logger.error(var17.getMessage(), var17);
- throw new ShrWebBizException("设置导入需求失败!");
- }
- SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
- SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
- .get("detailColl");
- if (!RecBaseUtils.isEmpty(detailColl)) {
- Iterator<SmartImportTaskDetailInfo> iter = detailColl.iterator();
- SmartImportTaskDetailInfo detailInfo = null;
- while (iter.hasNext()) {
- detailInfo = (SmartImportTaskDetailInfo) iter.next();
- if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
- && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState()) && !detailInfo.isIsDelete()) {
- SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
- newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
- newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
- newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
- newDetailInfo.setTaskState(TaskStateEnum.SAVED);
- newDetailInfo.setTask(newTaskInfo);
- newDetailColl.add(newDetailInfo);
- try {
- SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
- } catch (EASBizException var15) {
- logger.error(var15.getMessage(), var15);
- throw new ShrWebBizException("保存任务详情失败!");
- } catch (BOSException var16) {
- logger.error(var16.getMessage(), var16);
- throw new ShrWebBizException("保存任务详情失败!");
- }
- }
- }
- }
- if (newTaskInfo != null) {
- newTaskInfo.put("detailColl", newDetailColl);
- }
- try {
- SmartImportTaskEntity entity = new SmartImportTaskEntity(newTaskInfo,
- new ResumeSmartImportImpl(recuritmentDemandId));
- this.submitTask(entity);
- } catch (BOSException var14) {
- logger.error(var14.getMessage(), var14);
- throw new ShrWebBizException();
- }
- return this.getSmartImportTaskSchedule(newTaskInfo);
- }
- }
- }
- public void selfSmartImport(Context ctx, String taskId, String recuritmentDemandId, PersonInfo person,
- TaskTypeEnum taskType) throws ShrWebBizException {
- this.checkInfo(recuritmentDemandId, taskId, taskType);
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx,
- ContextUtil.getCurrentUserInfo(ctx).getId().toString(), taskType);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
- if (task == null) {
- throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
- } else {
- try {
- ISmartImportTask iSmartImportTask = SmartImportTaskFactory.getLocalInstance(ctx);
- task.setInterRecommendation(person);
- task.setSourceType(ResumeSourceType.SELF_UPLOAD);
- String sql;
- if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
- sql = "UPDATE T_REC_SmartImportTask SET FResumeClipID = '" + recuritmentDemandId
- + "',FSourceType = 4 WHERE FID = '" + taskId + "'";
- ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
- resumeClip.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- task.setResumeClip(resumeClip);
- } else {
- sql = "UPDATE T_REC_SmartImportTask SET FRecDemandID = '" + recuritmentDemandId
- + "',FSourceType = 4 WHERE FID = '" + taskId + "'";
- iSmartImportTask.setSmartImportChooseDemand(new ObjectUuidPK(task.getId()),
- new ObjectUuidPK(recuritmentDemandId));
- RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
- recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- task.setRecDemand(recDemandInfo);
- }
- DbUtil.execute(ctx, sql);
- } catch (BOSException var12) {
- logger.error("******************员工自助上传简历,设置智能导入所选简历夹/招聘需求失败!*****************");
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- try {
- SmartImportTaskEntity entity = null;
- if (taskType.equals(TaskTypeEnum.SELF_DEMAND)) {
- entity = new SmartImportTaskEntity(task,
- new ResumeSmartImportImpl(ctx, recuritmentDemandId, person, taskType));
- } else if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
- entity = new SmartImportTaskEntity(task,
- new ArchiveSmartImportImpl(ctx, recuritmentDemandId, person, taskType));
- }
- this.submitTask(entity);
- } catch (BOSException var11) {
- logger.error(var11.getMessage(), var11);
- throw new ShrWebBizException();
- }
- }
- }
- }
- public void resumeSmartImport(String taskId, TaskTypeEnum taskType, HashMap<String, String> paraMap)
- throws ShrWebBizException {
- String sourceType = "";
- String interRecommendationId = "";
- String resumeSourceId = "";
- String recuritmentDemandId = "";
- if(paraMap.containsKey("sourceType")) {
- sourceType = paraMap.get("sourceType");
- }
- if (paraMap.containsKey("interRecommendationId")) {
- interRecommendationId = paraMap.get("interRecommendationId");
- }
- if (paraMap.containsKey("resumeSourceId")) {
- resumeSourceId = paraMap.get("resumeSourceId");
- }
- if (paraMap.containsKey("recuritmentDemandId")) {
- recuritmentDemandId = paraMap.get("recuritmentDemandId");
- }
- if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
- if (StringUtils.isBlank(recuritmentDemandId)) {
- throw new ShrWebBizException("请选择简历夹!");
- }
- } else if (StringUtils.isBlank(recuritmentDemandId)) {
- throw new ShrWebBizException("请选择招聘需求!");
- }
- if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- logger.debug("recuritmentDemandId = " + recuritmentDemandId + ",taskId=" + taskId);
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(), taskType);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
- if (task == null) {
- throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
- } else {
- ResumeClipBaseInfo entity;
- if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
- new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
- entity = new ResumeClipBaseInfo();
- entity.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- task.setResumeClip(entity);
- } catch (BOSException var17) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var17.getMessage(), var17);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- } else {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
- new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
- RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
- recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- task.setRecDemand(recDemandInfo);
- } catch (BOSException var16) {
- logger.error("******************设置智能导入所选需求失败!*****************");
- logger.error(var16.getMessage(), var16);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- if (StringUtils.isNotEmpty(resumeSourceId)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
- new ObjectUuidPK(task.getId()), new ObjectUuidPK(resumeSourceId));
- ResumeSourceInfo resumeSourceInfo = new ResumeSourceInfo();
- resumeSourceInfo.setId(BOSUuid.read(resumeSourceId));
- task.setResumeSource(resumeSourceInfo);
- } catch (BOSException var15) {
- logger.error("******************设置智能导入简历来源失败!*****************");
- logger.error(var15.getMessage(), var15);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- if (StringUtils.isNotEmpty(interRecommendationId)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
- new ObjectUuidPK(task.getId().toString()), new ObjectUuidPK(interRecommendationId));
- PersonInfo personInfo = new PersonInfo();
- personInfo.setId(BOSUuid.read(interRecommendationId));
- task.setInterRecommendation(personInfo);
- } catch (BOSException var14) {
- logger.error("******************设置智能导入所选内部推荐人失败!*****************");
- logger.error(var14.getMessage(), var14);
- }
- }
- if (StringUtils.isNotEmpty(sourceType)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseSourceType(
- new ObjectUuidPK(task.getId().toString()), sourceType);
- task.setSourceType(ResumeSourceType.getEnum(Integer.parseInt(sourceType)));
- } catch (BOSException var13) {
- logger.error("******************设置智能导入所选来源类型失败!*****************");
- logger.error(var13.getMessage(), var13);
- }
- }
- // e二开字段
- // 是否重点人才
- if (paraMap.containsKey("isKeyTalent")) {
- task.put("isKeyTalent", paraMap.get("isKeyTalent"));
- }
- // 电话号码
- if (paraMap.containsKey("phoneModify")) {
- task.put("phoneModify", paraMap.get("phoneModify"));
- }
- // over
- try {
- SmartImportTaskEntity entity1;
- if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
- entity1 = new SmartImportTaskEntity(task, new RecommendResumeSmartImportImpl(
- recuritmentDemandId, interRecommendationId, sourceType));
- } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
- entity1 = new SmartImportTaskEntity(task, new ResumeSmartImportImpl(ctx, recuritmentDemandId,
- resumeSourceId, interRecommendationId, sourceType));
- } else {
- entity1 = new SmartImportTaskEntity(task, new ArchiveSmartImportImpl(ctx,
- recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
- }
- this.submitTask(entity1);
- } catch (BOSException var12) {
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException();
- }
- }
- }
- }
- }
- public SmartImportTask resumeSmartImportAgain(String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
- if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(), taskType);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo taskInfo = null;
- try {
- taskInfo = SmartImportTaskFactory.getRemoteInstance()
- .getSmartImportTaskSchedule(new ObjectUuidPK(user.getId()), taskType, taskId);
- } catch (BOSException var26) {
- logger.error(var26.getMessage(), var26);
- throw new ShrWebBizException("获取解析任务失败!");
- }
- String recuritmentDemandId = taskInfo.getRecDemand().getId().toString();
- String interRecommendationId = "";
- if (null != taskInfo.getInterRecommendation()) {
- interRecommendationId = taskInfo.getInterRecommendation().getId().toString();
- }
- String resumeSourceId = "";
- if (null != taskInfo.getResumeSource()) {
- resumeSourceId = taskInfo.getResumeSource().getId().toString();
- }
- String sourceType = "";
- if (null != taskInfo.getSourceType()) {
- sourceType = taskInfo.getSourceType().getValue() + "";
- }
- SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, taskType);
- if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
- new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
- ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
- resumeClip.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- newTaskInfo.setResumeClip(resumeClip);
- } catch (BOSException var25) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var25.getMessage(), var25);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- } else {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
- new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
- RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
- recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
- newTaskInfo.setRecDemand(recDemandInfo);
- } catch (BOSException var24) {
- logger.error("******************设置智能导入所选需求失败!*****************");
- logger.error(var24.getMessage(), var24);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- if (StringUtils.isNotEmpty(resumeSourceId)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
- new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeSourceId));
- ResumeSourceInfo resumeSourceInfo = new ResumeSourceInfo();
- resumeSourceInfo.setId(BOSUuid.read(resumeSourceId));
- newTaskInfo.setResumeSource(resumeSourceInfo);
- } catch (BOSException var23) {
- logger.error("******************设置智能导入简历来源失败!*****************");
- logger.error(var23.getMessage(), var23);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- if (StringUtils.isNotEmpty(interRecommendationId)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
- new ObjectUuidPK(newTaskInfo.getId().toString()),
- new ObjectUuidPK(interRecommendationId));
- PersonInfo personInfo = new PersonInfo();
- personInfo.setId(BOSUuid.read(interRecommendationId));
- newTaskInfo.setInterRecommendation(personInfo);
- } catch (BOSException var22) {
- logger.error("******************设置智能导入所选内部推荐人失败!*****************");
- logger.error(var22.getMessage(), var22);
- }
- }
- if (StringUtils.isNotEmpty(sourceType)) {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseSourceType(
- new ObjectUuidPK(newTaskInfo.getId().toString()), sourceType);
- newTaskInfo.setSourceType(ResumeSourceType.getEnum(Integer.parseInt(sourceType)));
- } catch (BOSException var21) {
- logger.error("******************设置智能导入所选内部推荐人失败!*****************");
- logger.error(var21.getMessage(), var21);
- }
- }
- SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
- SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
- .get("detailColl");
- Iterator entity;
- if (!RecBaseUtils.isEmpty(detailColl)) {
- entity = detailColl.iterator();
- SmartImportTaskDetailInfo detailInfo = null;
- while (entity.hasNext()) {
- detailInfo = (SmartImportTaskDetailInfo) entity.next();
- if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
- && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState()) && !detailInfo.isIsDelete()) {
- SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
- newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
- newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
- newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
- newDetailInfo.setTaskState(TaskStateEnum.SAVED);
- newDetailInfo.setTask(newTaskInfo);
- newDetailColl.add(newDetailInfo);
- try {
- SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
- } catch (EASBizException var19) {
- logger.error(var19.getMessage(), var19);
- throw new ShrWebBizException("保存任务详情失败!");
- } catch (BOSException var20) {
- logger.error(var20.getMessage(), var20);
- throw new ShrWebBizException("保存任务详情失败!");
- }
- }
- }
- }
- if (newTaskInfo != null) {
- newTaskInfo.put("detailColl", newDetailColl);
- }
- try {
- SmartImportTaskEntity entity1;
- if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
- entity1 = new SmartImportTaskEntity(newTaskInfo, new RecommendResumeSmartImportImpl(
- recuritmentDemandId, interRecommendationId, sourceType));
- } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
- entity1 = new SmartImportTaskEntity(newTaskInfo, new ResumeSmartImportImpl(ctx,
- recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
- } else {
- entity1 = new SmartImportTaskEntity(newTaskInfo, new ArchiveSmartImportImpl(ctx,
- recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
- }
- this.submitTask(entity1);
- } catch (BOSException var18) {
- logger.error(var18.getMessage(), var18);
- throw new ShrWebBizException();
- }
- return this.getSmartImportTaskSchedule(newTaskInfo);
- }
- }
- }
- private void checkInfo(String recuritmentDemandId, String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
- if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
- if (StringUtils.isBlank(recuritmentDemandId)) {
- throw new ShrWebBizException("请选择简历夹!");
- }
- } else if (StringUtils.isBlank(recuritmentDemandId)) {
- throw new ShrWebBizException("请选择招聘需求!");
- }
- if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- }
- }
- /** @deprecated */
- @Deprecated
- public void archiveSmartImport(String resumeClipId, String taskId) throws ShrWebBizException {
- if (StringUtils.isBlank(resumeClipId)) {
- throw new ShrWebBizException("请选择目标简历夹!");
- } else if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
- TaskTypeEnum.SMARTIMPORT_ARCHIVE);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
- if (task == null) {
- throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
- } else {
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
- new ObjectUuidPK(task.getId()), new ObjectUuidPK(resumeClipId));
- ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
- resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
- task.setResumeClip(resumeClip);
- } catch (BOSException var10) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var10.getMessage(), var10);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- try {
- SmartImportTaskEntity entity = new SmartImportTaskEntity(task,
- new ArchiveSmartImportImpl(resumeClipId));
- this.submitTask(entity);
- } catch (BOSException var9) {
- logger.error(var9.getMessage(), var9);
- throw new ShrWebBizException(var9.getMessage());
- }
- }
- }
- }
- }
- /** @deprecated */
- @Deprecated
- public SmartImportTask archiveSmartImportAgain(String taskId) throws ShrWebBizException {
- if (StringUtils.isBlank(taskId)) {
- throw new ShrWebBizException("解析任务ID不能为空!");
- } else {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- Context ctx = SHRContext.getInstance().getContext();
- SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
- TaskTypeEnum.SMARTIMPORT_ARCHIVE);
- if (runningTask != null) {
- throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
- } else {
- SmartImportTaskInfo taskInfo = null;
- try {
- taskInfo = SmartImportTaskFactory.getRemoteInstance().getSmartImportTaskSchedule(
- new ObjectUuidPK(user.getId()), TaskTypeEnum.SMARTIMPORT_ARCHIVE, taskId);
- } catch (BOSException var19) {
- logger.error(var19.getMessage(), var19);
- throw new ShrWebBizException("获取解析任务失败!");
- }
- String resumeClipId = taskInfo.getResumeClip().getId().toString();
- SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, TaskTypeEnum.SMARTIMPORT_ARCHIVE);
- try {
- SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
- new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeClipId));
- ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
- resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
- newTaskInfo.setResumeClip(resumeClip);
- } catch (BOSException var18) {
- logger.error("******************设置智能导入所选简历夹失败!*****************");
- logger.error(var18.getMessage(), var18);
- throw new ShrWebBizException("设置导入简历夹失败!");
- }
- SmartImportTask newTask = new SmartImportTask(newTaskInfo);
- SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
- SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
- .get("detailColl");
- if (!RecBaseUtils.isEmpty(detailColl)) {
- Iterator<SmartImportTaskDetailInfo> iter = detailColl.iterator();
- SmartImportTaskDetailInfo detailInfo = null;
- while (iter.hasNext()) {
- detailInfo = (SmartImportTaskDetailInfo) iter.next();
- if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
- && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
- SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
- newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
- newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
- newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
- newDetailInfo.setTaskState(TaskStateEnum.SAVED);
- newDetailInfo.setTask(newTaskInfo);
- newDetailColl.add(newDetailInfo);
- try {
- SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
- } catch (EASBizException var16) {
- logger.error(var16.getMessage(), var16);
- throw new ShrWebBizException("保存任务详情失败!");
- } catch (BOSException var17) {
- logger.error(var17.getMessage(), var17);
- throw new ShrWebBizException("保存任务详情失败!");
- }
- newTask.addNonExecuteTaskDetail(newDetailInfo);
- newTask.addTaskDetail(newDetailInfo);
- }
- }
- }
- newTask.setNonExecuteAmount(newDetailColl.size());
- newTask.setDoneAmount(0);
- newTask.setFailedAmount(0);
- newTask.setSuccessedAmount(0);
- newTask.setResumeAmount(newDetailColl.size());
- try {
- SmartImportTaskEntity entity = new SmartImportTaskEntity(newTaskInfo,
- new ArchiveSmartImportImpl(resumeClipId));
- this.submitTask(entity);
- return newTask;
- } catch (BOSException var15) {
- logger.error(var15.getMessage(), var15);
- throw new ShrWebBizException();
- }
- }
- }
- }
- private void submitTask(SmartImportTaskEntity taskEntity) throws ShrWebBizException {
- SmartImportTaskInfo task = taskEntity.getTaskInfo();
- try {
- SmartImportTaskFactory.getLocalInstance(taskEntity.getCtx()).taskSubmit(task);
- } catch (BOSException var4) {
- logger.error(var4.getMessage(), var4);
- throw new ShrWebBizException("任务提交异常,请稍后重试!");
- }
- Future future = RecSyncTaskThreadPool.getInstance().submitAsyncTask(taskEntity);
- this.afterSubmitTask(taskEntity, future);
- }
- private void afterSubmitTask(SmartImportTaskEntity taskEntity, Future future) {
- FutureTimeTask futureTimeTask = new FutureTimeTask(taskEntity, future);
- try {
- this.futureTaskQueue.put(futureTimeTask);
- } catch (InterruptedException var5) {
- logger.error("****************向添加超时任务队列添加任务失败!*****************");
- logger.error(var5.getMessage(), var5);
- }
- }
- public SmartImportTask getResumeSmartImportTaskSchedule(Context ctx, TaskTypeEnum taskType)
- throws ShrWebBizException {
- UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
- return this.getSmartImportTaskSchedule(ctx, user.getId().toString(), taskType);
- }
- private SmartImportTask getSmartImportTaskSchedule(SmartImportTaskInfo taskInfo) {
- SmartImportTask task = null;
- if (taskInfo != null) {
- task = new SmartImportTask(taskInfo);
- SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo.get("detailColl");
- if (!RecBaseUtils.isEmpty(detailColl)) {
- int i = 0;
- for (int size = detailColl.size(); i < size; ++i) {
- SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
- if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
- task.addSuccessTaskDetail(detailInfo);
- } else if (TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
- task.addNonExecuteTaskDetail(detailInfo);
- } else {
- task.addFailTaskDetail(detailInfo);
- }
- task.addTaskDetail(detailInfo);
- }
- task.setNonExecuteAmount(task.getNonExecuteDetails().size());
- task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
- task.setFailedAmount(task.getFailDetails().size());
- task.setSuccessedAmount(task.getSuccessDetails().size());
- task.setResumeAmount(task.getDetails().size());
- }
- }
- return task;
- }
- private SmartImportTask getSmartImportTaskSchedule(Context ctx, String userId, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = this.getRunningTask(ctx, userId, taskType);
- if (taskInfo != null) {
- SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
- taskInfo.put("detailColl", detailColl);
- return this.getSmartImportTaskSchedule(taskInfo);
- } else {
- taskInfo = this.getLastEndTask(ctx, userId, taskType);
- if (taskInfo != null) {
- SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
- SmartImportTaskDetailCollection detailColl;
- SmartImportTask task;
- if (savedTaskInfo != null) {
- detailColl = this.getTaskDetailCollection(ctx, savedTaskInfo.getId().toString());
- savedTaskInfo.put("detailColl", detailColl);
- task = this.getSmartImportTaskSchedule(savedTaskInfo);
- } else {
- task = new SmartImportTask();
- }
- task.setLastTaskInfo(taskInfo);
- detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
- int i = 0;
- for (int size = detailColl.size(); i < size; ++i) {
- SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
- if (!detailInfo.isIsDelete()) {
- if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
- task.addSuccessTaskDetail(detailInfo);
- } else {
- task.addFailTaskDetail(detailInfo);
- }
- task.addTaskDetail(detailInfo);
- }
- }
- task.setFailedAmount(task.getFailDetails().size());
- task.setSuccessedAmount(task.getSuccessDetails().size());
- task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
- task.setResumeAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
- return task;
- } else {
- SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
- if (savedTaskInfo != null) {
- SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx,
- savedTaskInfo.getId().toString());
- savedTaskInfo.put("detailColl", detailColl);
- return this.getSmartImportTaskSchedule(savedTaskInfo);
- } else {
- return null;
- }
- }
- }
- }
- private SmartImportTaskInfo getLastSavedTask(Context ctx, String userId, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = null;
- EntityViewInfo view = new EntityViewInfo();
- FilterInfo filter = new FilterInfo();
- filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.EQUALS));
- view.setFilter(filter);
- SorterItemCollection sorterColl = new SorterItemCollection();
- SorterItemInfo sorterItemInfo = new SorterItemInfo("createTime");
- sorterItemInfo.setSortType(SortType.DESCEND);
- sorterColl.add(sorterItemInfo);
- view.setSorter(sorterColl);
- SelectorItemCollection selector = new SelectorItemCollection();
- selector.add("*");
- selector.add("recDemand.*");
- selector.add("interRecommendation.*");
- selector.add("resumeSource.*");
- selector.add("recDemand.recuritPosition.*");
- selector.add("recDemand.hrJob.*");
- selector.add("resumeClip.*");
- view.setSelector(selector);
- try {
- SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
- .getSmartImportTaskCollection(view);
- if (!RecDBUtils.isEmpty(taskColl)) {
- taskInfo = taskColl.get(0);
- }
- return taskInfo;
- } catch (BOSException var12) {
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException("获取解析任务失败");
- }
- }
- private SmartImportTaskInfo getRunningTask(Context ctx, String userId, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = null;
- EntityViewInfo view = new EntityViewInfo();
- FilterInfo filter = new FilterInfo();
- filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.NOTEQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.NOTEQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.NOTEQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.NOTEQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 9, CompareType.NOTEQUALS));
- view.setFilter(filter);
- SorterItemCollection sorterColl = new SorterItemCollection();
- SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
- sorterItemInfo.setSortType(SortType.DESCEND);
- sorterColl.add(sorterItemInfo);
- view.setSorter(sorterColl);
- SelectorItemCollection selector = new SelectorItemCollection();
- selector.add("*");
- selector.add("recDemand.*");
- selector.add("interRecommendation.*");
- selector.add("resumeSource.*");
- selector.add("recDemand.recuritPosition.*");
- selector.add("recDemand.hrJob.*");
- selector.add("resumeClip.*");
- view.setSelector(selector);
- try {
- SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
- .getSmartImportTaskCollection(view);
- if (!RecDBUtils.isEmpty(taskColl)) {
- taskInfo = taskColl.get(0);
- }
- return taskInfo;
- } catch (BOSException var12) {
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException("获取正在运行中的解析任务失败");
- }
- }
- private SmartImportTaskInfo getLastEndTask(Context ctx, String userId, TaskTypeEnum taskType)
- throws ShrWebBizException {
- SmartImportTaskInfo taskInfo = null;
- EntityViewInfo view = new EntityViewInfo();
- FilterInfo filter = new FilterInfo();
- filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.EQUALS));
- filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.EQUALS));
- filter.setMaskString("#0 and #1 and (#2 or #3 or #4)");
- view.setFilter(filter);
- SorterItemCollection sorterColl = new SorterItemCollection();
- SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
- sorterItemInfo.setSortType(SortType.DESCEND);
- sorterColl.add(sorterItemInfo);
- view.setSorter(sorterColl);
- SelectorItemCollection selector = new SelectorItemCollection();
- selector.add("*");
- selector.add("recDemand.*");
- selector.add("interRecommendation.*");
- selector.add("resumeSource.*");
- selector.add("recDemand.recuritPosition.*");
- selector.add("recDemand.hrJob.*");
- selector.add("resumeClip.*");
- view.setSelector(selector);
- try {
- SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
- .getSmartImportTaskCollection(view);
- if (!RecDBUtils.isEmpty(taskColl)) {
- taskInfo = taskColl.get(0);
- }
- return taskInfo;
- } catch (BOSException var12) {
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException("获取解析任务失败");
- }
- }
- private SmartImportTaskDetailCollection getTaskDetailCollection(Context ctx, String taskId)
- throws ShrWebBizException {
- EntityViewInfo evi = new EntityViewInfo();
- FilterInfo filter01 = new FilterInfo();
- filter01.getFilterItems().add(new FilterItemInfo("task", taskId, CompareType.EQUALS));
- evi.setFilter(filter01);
- SelectorItemCollection selectorColl01 = evi.getSelector();
- selectorColl01.add(new SelectorItemInfo("id"));
- selectorColl01.add(new SelectorItemInfo("resumeFileName"));
- selectorColl01.add(new SelectorItemInfo("resumeFileType"));
- selectorColl01.add(new SelectorItemInfo("taskState"));
- selectorColl01.add(new SelectorItemInfo("info"));
- selectorColl01.add(new SelectorItemInfo("task"));
- selectorColl01.add(new SelectorItemInfo("isDelete"));
- SmartImportTaskDetailCollection detailColl = null;
- try {
- detailColl = SmartImportTaskDetailFactory.getLocalInstance(ctx).getSmartImportTaskDetailCollection(evi);
- return detailColl;
- } catch (BOSException var8) {
- logger.error(var8.getMessage(), var8);
- throw new ShrWebBizException("获取任务详情失败");
- }
- }
- public void affirmSmartImportTaskResult(String smartImportTaskId) throws ShrWebBizException {
- try {
- SmartImportTaskFactory.getRemoteInstance().affirmTask(new ObjectUuidPK(smartImportTaskId));
- } catch (BOSException var3) {
- logger.error(var3.getMessage(), var3);
- throw new ShrWebBizException("确认失败,请重试!");
- }
- }
- public void deleteResume(String taskDetailIds) throws ShrWebBizException {
- if (StringUtils.isEmpty(taskDetailIds)) {
- throw new ShrWebBizException("请选择要删除的简历!");
- } else {
- String[] detailAry = taskDetailIds.split(",");
- try {
- SmartImportTaskDetailFactory.getRemoteInstance().deleteResumes(detailAry);
- } catch (BOSException var4) {
- logger.error(var4.getMessage(), var4);
- throw new ShrWebBizException("服务器繁忙,请稍后重试!");
- }
- }
- }
- public void updateResume(Map<String, MultipartFile> fileMap, String resumeId, TaskTypeEnum taskType)
- throws ShrWebBizException {
- if (StringUtils.isEmpty(resumeId)) {
- throw new ShrWebBizException("简历更新失败,resumeId为空!");
- } else {
- Context ctx = SHRContext.getInstance().getContext();
- Iterator var5 = fileMap.entrySet().iterator();
- while (true) {
- if (var5.hasNext()) {
- Map.Entry<String, MultipartFile> entity = (Map.Entry) var5.next();
- MultipartFile mf = (MultipartFile) entity.getValue();
- FileSafeUtil.checkFileCompliance(ctx, mf, FILETYPELIST, "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF");
- String resumeFileName = mf.getOriginalFilename();
- byte[] resumeFileData = null;
- try {
- resumeFileData = mf.getBytes();
- } catch (IOException var12) {
- logger.error(var12.getMessage(), var12);
- throw new ShrWebBizException("附件上传失败,获取附件内容异常!");
- }
- if (StringUtils.isBlank(resumeFileName)) {
- throw new ShrWebBizException("简历附件名不能为空:" + resumeFileName);
- }
- if (resumeFileData != null && resumeFileData.length >= this.resumeFileMinSize) {
- if (resumeFileData.length > this.resumeFileMaxSize) {
- throw new ShrWebBizException("简历附件大小不能超过:" + this.resumeFileMaxSize / 1024 / 1024 + "M!");
- }
- try {
- boolean result = SmartResumeUpdateService.getInstance().smartResumeUpdate(ctx, mf, resumeId,
- taskType);
- if (!result) {
- throw new ShrWebBizException("简历更新失败,请联系系统管理员!");
- }
- continue;
- } catch (BOSException var11) {
- logger.error(var11.getMessage(), var11);
- throw new ShrWebBizException(var11.getMessage());
- }
- }
- throw new ShrWebBizException("简历附件不能为空!");
- }
- return;
- }
- }
- }
- public void recoverSmartImportTask(Context ctx) throws BOSException {
- if (logger.isDebugEnabled()) {
- logger.debug("**********启动智能导入恢复任务recoverSmartImportTask**********");
- }
- Calendar c = Calendar.getInstance();
- c.add(12, -35);
- Date timeout = c.getTime();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
- String timeoutStr = sdf.format(timeout);
- SmartImportTaskCollection taskColl = null;
- try {
- taskColl = SmartImportTaskFactory.getLocalInstance(ctx).getSmartImportTaskCollection(
- "where taskState = 9 or ((taskState = 4 or taskState = 2) and taskStartDate <= {ts'" + timeoutStr
- + "'})");
- } catch (BOSException var11) {
- logger.error("*************************************获取超时及异常任务失败!*************************************");
- logger.error(var11.getMessage(), var11);
- }
- if (!RecBaseUtils.isEmpty(taskColl)) {
- Iterator<SmartImportTaskInfo> iter = taskColl.iterator();
- SmartImportTaskInfo taskInfo = null;
- while (iter.hasNext()) {
- taskInfo = (SmartImportTaskInfo) iter.next();
- try {
- SmartImportTaskEntity TaskEntity = null;
- if (TaskTypeEnum.SMARTIMPORT_RESUME.equals(taskInfo.getTaskType())) {
- TaskEntity = new SmartImportTaskEntity(taskInfo, new ResumeSmartImportImpl(ctx,
- taskInfo.getRecDemand().getId().toString(),
- taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
- taskInfo.getInterRecommendation() == null ? ""
- : taskInfo.getInterRecommendation().getId().toString(),
- taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
- } else if (TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME.equals(taskInfo.getTaskType())) {
- TaskEntity = new SmartImportTaskEntity(taskInfo,
- new RecommendResumeSmartImportImpl(taskInfo.getRecDemand().getId().toString(),
- taskInfo.getInterRecommendation() == null ? ""
- : taskInfo.getInterRecommendation().getId().toString(),
- taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
- } else {
- TaskEntity = new SmartImportTaskEntity(taskInfo, new ArchiveSmartImportImpl(ctx,
- taskInfo.getResumeClip().getId().toString(),
- taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
- taskInfo.getInterRecommendation() == null ? ""
- : taskInfo.getInterRecommendation().getId().toString(),
- taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
- }
- if (TaskEntity != null) {
- this.submitTask(TaskEntity);
- }
- } catch (ShrWebBizException var10) {
- logger.error("*******************恢复" + taskInfo.getId() + "任务失败!*******************");
- logger.error(var10.getMessage(), var10);
- }
- }
- } else if (logger.isDebugEnabled()) {
- logger.debug("*************************************不存在超时及异常任务!*************************************");
- }
- }
- private class TimeoutTaskCheckThread implements Runnable {
- private TimeoutTaskCheckThread() {
- }
- public void run() {
- if (SmartImportServiceEx.logger.isDebugEnabled()) {
- SmartImportServiceEx.logger.debug("**************超时任务监控线程启动**************");
- }
- while (!Thread.currentThread().isInterrupted()) {
- try {
- FutureTimeTask future = (FutureTimeTask) SmartImportServiceEx.this.futureTaskQueue.take();
- if (!future.timeoutCancel()) {
- SmartImportServiceEx.this.futureTaskQueue.put(future);
- }
- Thread.sleep(100L);
- } catch (InterruptedException var2) {
- SmartImportServiceEx.logger.error("************************超时任务队列获取数据被异常中断***********************");
- SmartImportServiceEx.logger.error(var2.getMessage(), var2);
- } catch (Exception var3) {
- SmartImportServiceEx.logger.error("************************超时任务队列获取数据异常***********************");
- SmartImportServiceEx.logger.error(var3.getMessage(), var3);
- }
- }
- if (SmartImportServiceEx.logger.isDebugEnabled()) {
- SmartImportServiceEx.logger.debug("**************超时任务监控线程中断**************");
- }
- }
- }
- private class FutureTimeTask {
- private Future future;
- private SmartImportTaskEntity taskEntity;
- public FutureTimeTask(SmartImportTaskEntity taskEntity, Future future) {
- this.taskEntity = taskEntity;
- this.future = future;
- }
- public boolean timeoutCancel() {
- SmartImportTaskInfo taskInfo = this.taskEntity.getTaskInfo();
- if (taskInfo.getTaskState().equals(TaskStateEnum.RUNNING)) {
- if (!this.future.isDone()) {
- long now = System.currentTimeMillis();
- if (now - taskInfo.getTaskStartDate().getTime() <= SmartImportServiceEx.this.taskTimeoutMillis) {
- return false;
- }
- this.future.cancel(true);
- }
- } else if (taskInfo.getTaskState().equals(TaskStateEnum.SUBMITED)) {
- return false;
- }
- return true;
- }
- }
- private static class SmartImportServiceHolder {
- private static final SmartImportServiceEx service = new SmartImportServiceEx();
- private SmartImportServiceHolder() {
- }
- }
- }
|