SmartImportServiceEx.java 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. package com.kingdee.shr.recuritment.service.smartimport;
  2. import java.io.IOException;
  3. import java.io.UnsupportedEncodingException;
  4. import java.text.SimpleDateFormat;
  5. import java.util.Arrays;
  6. import java.util.Calendar;
  7. import java.util.Date;
  8. import java.util.HashMap;
  9. import java.util.Iterator;
  10. import java.util.List;
  11. import java.util.Map;
  12. import java.util.concurrent.BlockingQueue;
  13. import java.util.concurrent.Future;
  14. import java.util.concurrent.LinkedBlockingQueue;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.apache.log4j.Logger;
  17. import org.springframework.web.multipart.MultipartFile;
  18. import com.kingdee.bos.BOSException;
  19. import com.kingdee.bos.Context;
  20. import com.kingdee.bos.dao.IObjectPK;
  21. import com.kingdee.bos.dao.ormapping.ObjectUuidPK;
  22. import com.kingdee.bos.metadata.data.SortType;
  23. import com.kingdee.bos.metadata.entity.EntityViewInfo;
  24. import com.kingdee.bos.metadata.entity.FilterInfo;
  25. import com.kingdee.bos.metadata.entity.FilterItemInfo;
  26. import com.kingdee.bos.metadata.entity.SelectorItemCollection;
  27. import com.kingdee.bos.metadata.entity.SelectorItemInfo;
  28. import com.kingdee.bos.metadata.entity.SorterItemCollection;
  29. import com.kingdee.bos.metadata.entity.SorterItemInfo;
  30. import com.kingdee.bos.metadata.query.util.CompareType;
  31. import com.kingdee.bos.util.BOSUuid;
  32. import com.kingdee.eas.base.permission.UserInfo;
  33. import com.kingdee.eas.basedata.person.PersonInfo;
  34. import com.kingdee.eas.common.EASBizException;
  35. import com.kingdee.eas.util.app.ContextUtil;
  36. import com.kingdee.eas.util.app.DbUtil;
  37. import com.kingdee.shr.base.syssetting.context.SHRContext;
  38. import com.kingdee.shr.base.syssetting.exception.ShrWebBizException;
  39. import com.kingdee.shr.recuritment.ISmartImportTask;
  40. import com.kingdee.shr.recuritment.RecuritmentDemandInfo;
  41. import com.kingdee.shr.recuritment.ResumeClipBaseInfo;
  42. import com.kingdee.shr.recuritment.ResumeSourceInfo;
  43. import com.kingdee.shr.recuritment.ResumeSourceType;
  44. import com.kingdee.shr.recuritment.SmartImportTaskCollection;
  45. import com.kingdee.shr.recuritment.SmartImportTaskDetailCollection;
  46. import com.kingdee.shr.recuritment.SmartImportTaskDetailFactory;
  47. import com.kingdee.shr.recuritment.SmartImportTaskDetailInfo;
  48. import com.kingdee.shr.recuritment.SmartImportTaskFactory;
  49. import com.kingdee.shr.recuritment.SmartImportTaskInfo;
  50. import com.kingdee.shr.recuritment.TaskStateEnum;
  51. import com.kingdee.shr.recuritment.TaskTypeEnum;
  52. import com.kingdee.shr.recuritment.app.util.EncodingDetect;
  53. import com.kingdee.shr.recuritment.app.util.db.RecDBUtils;
  54. import com.kingdee.shr.recuritment.app.util.job.RecSyncTaskThreadPool;
  55. import com.kingdee.shr.recuritment.service.smartimport.base.impl.ArchiveSmartImportImpl;
  56. import com.kingdee.shr.recuritment.service.smartimport.base.impl.RecommendResumeSmartImportImpl;
  57. import com.kingdee.shr.recuritment.service.smartimport.base.impl.ResumeSmartImportImpl;
  58. import com.kingdee.shr.recuritment.service.smartimport.entity.SmartImportTaskEntity;
  59. import com.kingdee.shr.recuritment.util.FileSafeUtil;
  60. import com.kingdee.shr.recuritment.util.RecWebBaseUtils;
  61. import com.kingdee.shr.recuritment.util.XSSDefenseUtil;
  62. import com.kingdee.shr.recuritment.util.vo.smartimport.SmartImportTask;
  63. import com.kingdee.shr.recuritment.utils.RecBaseUtils;
  64. public class SmartImportServiceEx {
  65. private static final Logger logger = Logger.getLogger(SmartImportServiceEx.class);
  66. private long taskTimeoutMillis;
  67. private final BlockingQueue<FutureTimeTask> futureTaskQueue;
  68. private static final List<Object> FILETYPELIST = Arrays.asList("DOC", "DOCX", "TXT", "RTF", "PDF", "MSG", "WPS",
  69. "JPG", "PNG", "GIF");
  70. private static final String FILETYPESTR = "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF";
  71. private int resumeFileMinSize;
  72. private int resumeFileMaxSize;
  73. private SmartImportServiceEx() {
  74. this.taskTimeoutMillis = 1800000L;
  75. this.resumeFileMinSize = 1;
  76. this.resumeFileMaxSize = 20971520;
  77. this.futureTaskQueue = new LinkedBlockingQueue();
  78. RecSyncTaskThreadPool.getInstance().submitAsyncTask(new TimeoutTaskCheckThread());
  79. }
  80. public static SmartImportServiceEx getInstance() throws ShrWebBizException {
  81. return SmartImportServiceEx.SmartImportServiceHolder.service;
  82. }
  83. public void setSmartImportChooseDemand(String recuritmentDemandId) throws ShrWebBizException {
  84. this.setSmartImportChooseDemand(recuritmentDemandId, TaskTypeEnum.SMARTIMPORT_RESUME);
  85. }
  86. public void setSmartImportChooseDemand(String recuritmentDemandId, TaskTypeEnum typeEnum)
  87. throws ShrWebBizException {
  88. SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(typeEnum);
  89. if (taskInfo != null) {
  90. try {
  91. IObjectPK recuritmentDemandPK = recuritmentDemandId == null ? null
  92. : new ObjectUuidPK(recuritmentDemandId);
  93. SmartImportTaskFactory.getRemoteInstance()
  94. .setSmartImportChooseDemand(new ObjectUuidPK(taskInfo.getId().toString()), recuritmentDemandPK);
  95. } catch (BOSException var5) {
  96. logger.error("******************设置智能导入所选需求失败!*****************");
  97. logger.error(var5.getMessage(), var5);
  98. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  99. }
  100. }
  101. }
  102. public void setSmartImportChooseResumeClip(String resumeClipId, TaskTypeEnum taskType) throws ShrWebBizException {
  103. SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
  104. if (taskInfo != null) {
  105. try {
  106. IObjectPK resumeClipPK = resumeClipId == null ? null : new ObjectUuidPK(resumeClipId);
  107. SmartImportTaskFactory.getRemoteInstance()
  108. .setSmartImportChooseResumeClip(new ObjectUuidPK(taskInfo.getId().toString()), resumeClipPK);
  109. } catch (BOSException var5) {
  110. logger.error("******************设置智能导入所选简历夹失败!*****************");
  111. logger.error(var5.getMessage(), var5);
  112. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  113. }
  114. }
  115. }
  116. public void setSmartImportChooseRecommendation(String interRecommendation, TaskTypeEnum taskType)
  117. throws ShrWebBizException {
  118. SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
  119. if (taskInfo != null) {
  120. try {
  121. IObjectPK interRecommendationId = interRecommendation == null ? null
  122. : new ObjectUuidPK(interRecommendation);
  123. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
  124. new ObjectUuidPK(taskInfo.getId().toString()), interRecommendationId);
  125. } catch (BOSException var5) {
  126. logger.error("******************设置智能导入所选简历夹失败!*****************");
  127. logger.error(var5.getMessage(), var5);
  128. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  129. }
  130. }
  131. }
  132. public void setSmartImportChooseResumeSource(String resumeSource, TaskTypeEnum taskType) throws ShrWebBizException {
  133. SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
  134. if (taskInfo != null) {
  135. try {
  136. IObjectPK resumeSourceId = resumeSource == null ? null : new ObjectUuidPK(resumeSource);
  137. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
  138. new ObjectUuidPK(taskInfo.getId().toString()), resumeSourceId);
  139. } catch (BOSException var5) {
  140. logger.error("******************设置智能导入所选简历夹失败!*****************");
  141. logger.error(var5.getMessage(), var5);
  142. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  143. }
  144. }
  145. }
  146. public void setSmartImportChooseSourceType(String sourceType, TaskTypeEnum taskType) throws ShrWebBizException {
  147. SmartImportTaskInfo taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
  148. if (taskInfo != null) {
  149. try {
  150. SmartImportTaskFactory.getRemoteInstance()
  151. .setSmartImportChooseSourceType(new ObjectUuidPK(taskInfo.getId().toString()), sourceType);
  152. } catch (BOSException var5) {
  153. logger.error("******************设置智能导入所选来源类型失败!*****************");
  154. logger.error(var5.getMessage(), var5);
  155. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  156. }
  157. }
  158. }
  159. /** @deprecated */
  160. @Deprecated
  161. public SmartImportTask uploadResume(Map<String, MultipartFile> fileMap, String taskId, String recuritmentDemandId)
  162. throws ShrWebBizException {
  163. SmartImportTask taskData = this.doUploadResume(fileMap, TaskTypeEnum.SMARTIMPORT_RESUME);
  164. return taskData;
  165. }
  166. /** @deprecated */
  167. @Deprecated
  168. public SmartImportTask uploadArchiveResume(Map<String, MultipartFile> fileMap, String taskId, String resumeClipId)
  169. throws ShrWebBizException {
  170. SmartImportTask taskData = this.doUploadResume(fileMap, TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  171. return taskData;
  172. }
  173. public SmartImportTask uploadResume(Map<String, MultipartFile> fileMap, TaskTypeEnum type)
  174. throws ShrWebBizException {
  175. SmartImportTask taskData = this.doUploadResume(fileMap, type);
  176. return taskData;
  177. }
  178. private SmartImportTask doUploadResume(Map<String, MultipartFile> fileMap, TaskTypeEnum taskType)
  179. throws ShrWebBizException {
  180. SmartImportTaskInfo taskInfo = null;
  181. SmartImportTaskDetailCollection detailColl = new SmartImportTaskDetailCollection();
  182. Context ctx = SHRContext.getInstance().getContext();
  183. Iterator var6 = fileMap.entrySet().iterator();
  184. while (true) {
  185. if (var6.hasNext()) {
  186. Map.Entry<String, MultipartFile> entity = (Map.Entry) var6.next();
  187. MultipartFile mf = (MultipartFile) entity.getValue();
  188. String resumeFileName = mf.getOriginalFilename();
  189. byte[] resumeFileData = null;
  190. try {
  191. resumeFileData = mf.getBytes();
  192. } catch (IOException var16) {
  193. logger.error(var16.getMessage(), var16);
  194. throw new ShrWebBizException("附件上传失败,获取附件内容异常!");
  195. }
  196. if (StringUtils.isBlank(resumeFileName)) {
  197. throw new ShrWebBizException("简历附件名不能为空:" + resumeFileName);
  198. }
  199. if (resumeFileData != null && resumeFileData.length >= this.resumeFileMinSize) {
  200. if (resumeFileData.length > this.resumeFileMaxSize) {
  201. throw new ShrWebBizException("简历附件大小不能超过:" + this.resumeFileMaxSize / 1024 / 1024 + "M!");
  202. }
  203. resumeFileData = FileSafeUtil.checkFileComplianceIncloudXSS(ctx, mf, FILETYPELIST,
  204. "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF");
  205. if (taskInfo == null) {
  206. taskInfo = this.getUserProgressTaskOrAddNotExists(taskType);
  207. }
  208. if (taskInfo == null) {
  209. if (logger.isDebugEnabled()) {
  210. logger.debug("上传简历失败,上传简历时获取任务失败");
  211. }
  212. throw new ShrWebBizException("上传简历失败。");
  213. }
  214. String fileType = resumeFileName.substring(resumeFileName.lastIndexOf(".") + 1);
  215. if (!StringUtils.equalsIgnoreCase("xls", fileType)
  216. && !StringUtils.equalsIgnoreCase("xlsx", fileType) && !resumeFileName.contains("csv")) {
  217. String encode;
  218. if (StringUtils.equals("text/html", fileType) || resumeFileName.contains("html")) {
  219. encode = EncodingDetect.getJavaEncode(resumeFileData);
  220. try {
  221. resumeFileData = XSSDefenseUtil.cleanXSS(new String(resumeFileData, encode))
  222. .getBytes(encode);
  223. } catch (UnsupportedEncodingException var15) {
  224. logger.error(var15.getMessage(), var15);
  225. throw new ShrWebBizException("上传简历失败。");
  226. }
  227. }
  228. encode = null;
  229. SmartImportTaskDetailInfo taskDetailInfo;
  230. try {
  231. taskDetailInfo = SmartImportTaskDetailFactory.getRemoteInstance()
  232. .addUploadResumeFile(resumeFileName, resumeFileData, taskInfo);
  233. } catch (BOSException var14) {
  234. logger.error("上传简历失败" + var14.getMessage());
  235. logger.error(var14.getMessage(), var14);
  236. throw new ShrWebBizException("上传简历失败。");
  237. }
  238. if (taskDetailInfo != null) {
  239. detailColl.add(taskDetailInfo);
  240. }
  241. continue;
  242. }
  243. throw new ShrWebBizException("非法文件!");
  244. }
  245. throw new ShrWebBizException("简历附件不能为空!");
  246. }
  247. if (taskInfo != null) {
  248. taskInfo.put("detailColl", detailColl);
  249. }
  250. return this.getSmartImportTaskSchedule(taskInfo);
  251. }
  252. }
  253. private synchronized SmartImportTaskInfo getUserProgressTaskOrAddNotExists(TaskTypeEnum taskType)
  254. throws ShrWebBizException {
  255. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  256. SmartImportTaskInfo taskInfo = this.getUserProgressSmartImportTask(user, taskType);
  257. if (taskInfo == null) {
  258. taskInfo = this.addUserProgressTask(user, taskType);
  259. }
  260. return taskInfo;
  261. }
  262. private SmartImportTaskInfo getUserProgressSmartImportTask(UserInfo user, TaskTypeEnum taskType)
  263. throws ShrWebBizException {
  264. try {
  265. SmartImportTaskInfo taskInfo = SmartImportTaskFactory.getRemoteInstance()
  266. .getUserProgressTask(new ObjectUuidPK(user.getId()), taskType);
  267. return taskInfo;
  268. } catch (BOSException var4) {
  269. logger.error(var4.getMessage(), var4);
  270. throw new ShrWebBizException("获取解析任务失败!");
  271. }
  272. }
  273. private SmartImportTaskInfo getSmartImportTaskById(String taskId) throws ShrWebBizException {
  274. try {
  275. SmartImportTaskInfo taskInfo = SmartImportTaskFactory.getRemoteInstance()
  276. .getSmartImportTaskInfo(new ObjectUuidPK(taskId));
  277. return taskInfo;
  278. } catch (EASBizException var3) {
  279. logger.error(var3.getMessage(), var3);
  280. throw new ShrWebBizException("获取解析任务失败!");
  281. } catch (BOSException var4) {
  282. logger.error(var4.getMessage(), var4);
  283. throw new ShrWebBizException("获取解析任务失败!");
  284. }
  285. }
  286. private SmartImportTaskInfo addUserProgressTask(UserInfo user, TaskTypeEnum taskType) throws ShrWebBizException {
  287. SmartImportTaskInfo taskInfo = null;
  288. try {
  289. taskInfo = SmartImportTaskFactory.getRemoteInstance().addUserProgressTask(user, taskType);
  290. return taskInfo;
  291. } catch (BOSException var5) {
  292. logger.error(var5.getMessage(), var5);
  293. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  294. }
  295. }
  296. /** @deprecated */
  297. @Deprecated
  298. public void resumeSmartImport(String recuritmentDemandId, String taskId) throws ShrWebBizException {
  299. if (StringUtils.isBlank(recuritmentDemandId)) {
  300. throw new ShrWebBizException("请选择招聘需求!");
  301. } else if (StringUtils.isBlank(taskId)) {
  302. throw new ShrWebBizException("解析任务ID不能为空!");
  303. } else {
  304. logger.debug("recuritmentDemandId = " + recuritmentDemandId + ",taskId=" + taskId);
  305. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  306. Context ctx = SHRContext.getInstance().getContext();
  307. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  308. TaskTypeEnum.SMARTIMPORT_RESUME);
  309. if (runningTask != null) {
  310. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  311. } else {
  312. SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
  313. if (task == null) {
  314. throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
  315. } else {
  316. try {
  317. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
  318. new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
  319. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  320. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  321. task.setRecDemand(recDemandInfo);
  322. } catch (BOSException var9) {
  323. logger.error("******************设置智能导入所选需求失败!*****************");
  324. logger.error(var9.getMessage(), var9);
  325. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  326. }
  327. try {
  328. SmartImportTaskEntity entity = new SmartImportTaskEntity(task,
  329. new ResumeSmartImportImpl(recuritmentDemandId));
  330. this.submitTask(entity);
  331. } catch (BOSException var8) {
  332. logger.error(var8.getMessage(), var8);
  333. throw new ShrWebBizException();
  334. }
  335. }
  336. }
  337. }
  338. }
  339. /** @deprecated */
  340. @Deprecated
  341. public SmartImportTask resumeSmartImportAgain(String taskId) throws ShrWebBizException {
  342. if (StringUtils.isBlank(taskId)) {
  343. throw new ShrWebBizException("解析任务ID不能为空!");
  344. } else {
  345. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  346. Context ctx = SHRContext.getInstance().getContext();
  347. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  348. TaskTypeEnum.SMARTIMPORT_RESUME);
  349. if (runningTask != null) {
  350. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  351. } else {
  352. SmartImportTaskInfo taskInfo = null;
  353. try {
  354. taskInfo = SmartImportTaskFactory.getRemoteInstance().getSmartImportTaskSchedule(
  355. new ObjectUuidPK(user.getId()), TaskTypeEnum.SMARTIMPORT_RESUME, taskId);
  356. } catch (BOSException var18) {
  357. logger.error(var18.getMessage(), var18);
  358. throw new ShrWebBizException("获取解析任务失败!");
  359. }
  360. String recuritmentDemandId = taskInfo.getRecDemand().getId().toString();
  361. SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, TaskTypeEnum.SMARTIMPORT_RESUME);
  362. try {
  363. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
  364. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
  365. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  366. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  367. newTaskInfo.setRecDemand(recDemandInfo);
  368. } catch (BOSException var17) {
  369. logger.error("******************设置智能导入所选需求失败!*****************");
  370. logger.error(var17.getMessage(), var17);
  371. throw new ShrWebBizException("设置导入需求失败!");
  372. }
  373. SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
  374. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
  375. .get("detailColl");
  376. if (!RecBaseUtils.isEmpty(detailColl)) {
  377. Iterator<SmartImportTaskDetailInfo> iter = detailColl.iterator();
  378. SmartImportTaskDetailInfo detailInfo = null;
  379. while (iter.hasNext()) {
  380. detailInfo = (SmartImportTaskDetailInfo) iter.next();
  381. if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
  382. && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState()) && !detailInfo.isIsDelete()) {
  383. SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
  384. newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
  385. newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
  386. newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
  387. newDetailInfo.setTaskState(TaskStateEnum.SAVED);
  388. newDetailInfo.setTask(newTaskInfo);
  389. newDetailColl.add(newDetailInfo);
  390. try {
  391. SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
  392. } catch (EASBizException var15) {
  393. logger.error(var15.getMessage(), var15);
  394. throw new ShrWebBizException("保存任务详情失败!");
  395. } catch (BOSException var16) {
  396. logger.error(var16.getMessage(), var16);
  397. throw new ShrWebBizException("保存任务详情失败!");
  398. }
  399. }
  400. }
  401. }
  402. if (newTaskInfo != null) {
  403. newTaskInfo.put("detailColl", newDetailColl);
  404. }
  405. try {
  406. SmartImportTaskEntity entity = new SmartImportTaskEntity(newTaskInfo,
  407. new ResumeSmartImportImpl(recuritmentDemandId));
  408. this.submitTask(entity);
  409. } catch (BOSException var14) {
  410. logger.error(var14.getMessage(), var14);
  411. throw new ShrWebBizException();
  412. }
  413. return this.getSmartImportTaskSchedule(newTaskInfo);
  414. }
  415. }
  416. }
  417. public void selfSmartImport(Context ctx, String taskId, String recuritmentDemandId, PersonInfo person,
  418. TaskTypeEnum taskType) throws ShrWebBizException {
  419. this.checkInfo(recuritmentDemandId, taskId, taskType);
  420. SmartImportTaskInfo runningTask = this.getRunningTask(ctx,
  421. ContextUtil.getCurrentUserInfo(ctx).getId().toString(), taskType);
  422. if (runningTask != null) {
  423. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  424. } else {
  425. SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
  426. if (task == null) {
  427. throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
  428. } else {
  429. try {
  430. ISmartImportTask iSmartImportTask = SmartImportTaskFactory.getLocalInstance(ctx);
  431. task.setInterRecommendation(person);
  432. task.setSourceType(ResumeSourceType.SELF_UPLOAD);
  433. String sql;
  434. if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
  435. sql = "UPDATE T_REC_SmartImportTask SET FResumeClipID = '" + recuritmentDemandId
  436. + "',FSourceType = 4 WHERE FID = '" + taskId + "'";
  437. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  438. resumeClip.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  439. task.setResumeClip(resumeClip);
  440. } else {
  441. sql = "UPDATE T_REC_SmartImportTask SET FRecDemandID = '" + recuritmentDemandId
  442. + "',FSourceType = 4 WHERE FID = '" + taskId + "'";
  443. iSmartImportTask.setSmartImportChooseDemand(new ObjectUuidPK(task.getId()),
  444. new ObjectUuidPK(recuritmentDemandId));
  445. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  446. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  447. task.setRecDemand(recDemandInfo);
  448. }
  449. DbUtil.execute(ctx, sql);
  450. } catch (BOSException var12) {
  451. logger.error("******************员工自助上传简历,设置智能导入所选简历夹/招聘需求失败!*****************");
  452. logger.error(var12.getMessage(), var12);
  453. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  454. }
  455. try {
  456. SmartImportTaskEntity entity = null;
  457. if (taskType.equals(TaskTypeEnum.SELF_DEMAND)) {
  458. entity = new SmartImportTaskEntity(task,
  459. new ResumeSmartImportImpl(ctx, recuritmentDemandId, person, taskType));
  460. } else if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
  461. entity = new SmartImportTaskEntity(task,
  462. new ArchiveSmartImportImpl(ctx, recuritmentDemandId, person, taskType));
  463. }
  464. this.submitTask(entity);
  465. } catch (BOSException var11) {
  466. logger.error(var11.getMessage(), var11);
  467. throw new ShrWebBizException();
  468. }
  469. }
  470. }
  471. }
  472. public void resumeSmartImport(String taskId, TaskTypeEnum taskType, HashMap<String, String> paraMap)
  473. throws ShrWebBizException {
  474. String sourceType = "";
  475. String interRecommendationId = "";
  476. String resumeSourceId = "";
  477. String recuritmentDemandId = "";
  478. if(paraMap.containsKey("sourceType")) {
  479. sourceType = paraMap.get("sourceType");
  480. }
  481. if (paraMap.containsKey("interRecommendationId")) {
  482. interRecommendationId = paraMap.get("interRecommendationId");
  483. }
  484. if (paraMap.containsKey("resumeSourceId")) {
  485. resumeSourceId = paraMap.get("resumeSourceId");
  486. }
  487. if (paraMap.containsKey("recuritmentDemandId")) {
  488. recuritmentDemandId = paraMap.get("recuritmentDemandId");
  489. }
  490. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
  491. if (StringUtils.isBlank(recuritmentDemandId)) {
  492. throw new ShrWebBizException("请选择简历夹!");
  493. }
  494. } else if (StringUtils.isBlank(recuritmentDemandId)) {
  495. throw new ShrWebBizException("请选择招聘需求!");
  496. }
  497. if (StringUtils.isBlank(taskId)) {
  498. throw new ShrWebBizException("解析任务ID不能为空!");
  499. } else {
  500. logger.debug("recuritmentDemandId = " + recuritmentDemandId + ",taskId=" + taskId);
  501. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  502. Context ctx = SHRContext.getInstance().getContext();
  503. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(), taskType);
  504. if (runningTask != null) {
  505. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  506. } else {
  507. SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
  508. if (task == null) {
  509. throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
  510. } else {
  511. ResumeClipBaseInfo entity;
  512. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
  513. try {
  514. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  515. new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
  516. entity = new ResumeClipBaseInfo();
  517. entity.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  518. task.setResumeClip(entity);
  519. } catch (BOSException var17) {
  520. logger.error("******************设置智能导入所选简历夹失败!*****************");
  521. logger.error(var17.getMessage(), var17);
  522. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  523. }
  524. } else {
  525. try {
  526. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
  527. new ObjectUuidPK(task.getId()), new ObjectUuidPK(recuritmentDemandId));
  528. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  529. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  530. task.setRecDemand(recDemandInfo);
  531. } catch (BOSException var16) {
  532. logger.error("******************设置智能导入所选需求失败!*****************");
  533. logger.error(var16.getMessage(), var16);
  534. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  535. }
  536. }
  537. if (StringUtils.isNotEmpty(resumeSourceId)) {
  538. try {
  539. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
  540. new ObjectUuidPK(task.getId()), new ObjectUuidPK(resumeSourceId));
  541. ResumeSourceInfo resumeSourceInfo = new ResumeSourceInfo();
  542. resumeSourceInfo.setId(BOSUuid.read(resumeSourceId));
  543. task.setResumeSource(resumeSourceInfo);
  544. } catch (BOSException var15) {
  545. logger.error("******************设置智能导入简历来源失败!*****************");
  546. logger.error(var15.getMessage(), var15);
  547. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  548. }
  549. }
  550. if (StringUtils.isNotEmpty(interRecommendationId)) {
  551. try {
  552. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
  553. new ObjectUuidPK(task.getId().toString()), new ObjectUuidPK(interRecommendationId));
  554. PersonInfo personInfo = new PersonInfo();
  555. personInfo.setId(BOSUuid.read(interRecommendationId));
  556. task.setInterRecommendation(personInfo);
  557. } catch (BOSException var14) {
  558. logger.error("******************设置智能导入所选内部推荐人失败!*****************");
  559. logger.error(var14.getMessage(), var14);
  560. }
  561. }
  562. if (StringUtils.isNotEmpty(sourceType)) {
  563. try {
  564. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseSourceType(
  565. new ObjectUuidPK(task.getId().toString()), sourceType);
  566. task.setSourceType(ResumeSourceType.getEnum(Integer.parseInt(sourceType)));
  567. } catch (BOSException var13) {
  568. logger.error("******************设置智能导入所选来源类型失败!*****************");
  569. logger.error(var13.getMessage(), var13);
  570. }
  571. }
  572. // e二开字段
  573. // 是否重点人才
  574. if (paraMap.containsKey("isKeyTalent")) {
  575. if (StringUtils.equals(paraMap.get("isKeyTalent"), "true")) {
  576. task.put("isKeyTalent", 1);
  577. } else {
  578. task.put("isKeyTalent", 0);
  579. }
  580. }
  581. // 电话号码
  582. if (paraMap.containsKey("phoneModify")) {
  583. task.put("phoneModify", paraMap.get("phoneModify"));
  584. }
  585. // over
  586. try {
  587. SmartImportTaskEntity entity1;
  588. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
  589. entity1 = new SmartImportTaskEntity(task, new RecommendResumeSmartImportImpl(
  590. recuritmentDemandId, interRecommendationId, sourceType));
  591. } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
  592. entity1 = new SmartImportTaskEntity(task, new ResumeSmartImportImpl(ctx, recuritmentDemandId,
  593. resumeSourceId, interRecommendationId, sourceType));
  594. } else {
  595. entity1 = new SmartImportTaskEntity(task, new ArchiveSmartImportImpl(ctx,
  596. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  597. }
  598. this.submitTask(entity1);
  599. } catch (BOSException var12) {
  600. logger.error(var12.getMessage(), var12);
  601. throw new ShrWebBizException();
  602. }
  603. }
  604. }
  605. }
  606. }
  607. public SmartImportTask resumeSmartImportAgain(String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
  608. if (StringUtils.isBlank(taskId)) {
  609. throw new ShrWebBizException("解析任务ID不能为空!");
  610. } else {
  611. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  612. Context ctx = SHRContext.getInstance().getContext();
  613. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(), taskType);
  614. if (runningTask != null) {
  615. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  616. } else {
  617. SmartImportTaskInfo taskInfo = null;
  618. try {
  619. taskInfo = SmartImportTaskFactory.getRemoteInstance()
  620. .getSmartImportTaskSchedule(new ObjectUuidPK(user.getId()), taskType, taskId);
  621. } catch (BOSException var26) {
  622. logger.error(var26.getMessage(), var26);
  623. throw new ShrWebBizException("获取解析任务失败!");
  624. }
  625. String recuritmentDemandId = taskInfo.getRecDemand().getId().toString();
  626. String interRecommendationId = "";
  627. if (null != taskInfo.getInterRecommendation()) {
  628. interRecommendationId = taskInfo.getInterRecommendation().getId().toString();
  629. }
  630. String resumeSourceId = "";
  631. if (null != taskInfo.getResumeSource()) {
  632. resumeSourceId = taskInfo.getResumeSource().getId().toString();
  633. }
  634. String sourceType = "";
  635. if (null != taskInfo.getSourceType()) {
  636. sourceType = taskInfo.getSourceType().getValue() + "";
  637. }
  638. SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, taskType);
  639. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
  640. try {
  641. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  642. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
  643. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  644. resumeClip.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  645. newTaskInfo.setResumeClip(resumeClip);
  646. } catch (BOSException var25) {
  647. logger.error("******************设置智能导入所选简历夹失败!*****************");
  648. logger.error(var25.getMessage(), var25);
  649. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  650. }
  651. } else {
  652. try {
  653. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
  654. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
  655. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  656. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  657. newTaskInfo.setRecDemand(recDemandInfo);
  658. } catch (BOSException var24) {
  659. logger.error("******************设置智能导入所选需求失败!*****************");
  660. logger.error(var24.getMessage(), var24);
  661. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  662. }
  663. }
  664. if (StringUtils.isNotEmpty(resumeSourceId)) {
  665. try {
  666. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
  667. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeSourceId));
  668. ResumeSourceInfo resumeSourceInfo = new ResumeSourceInfo();
  669. resumeSourceInfo.setId(BOSUuid.read(resumeSourceId));
  670. newTaskInfo.setResumeSource(resumeSourceInfo);
  671. } catch (BOSException var23) {
  672. logger.error("******************设置智能导入简历来源失败!*****************");
  673. logger.error(var23.getMessage(), var23);
  674. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  675. }
  676. }
  677. if (StringUtils.isNotEmpty(interRecommendationId)) {
  678. try {
  679. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
  680. new ObjectUuidPK(newTaskInfo.getId().toString()),
  681. new ObjectUuidPK(interRecommendationId));
  682. PersonInfo personInfo = new PersonInfo();
  683. personInfo.setId(BOSUuid.read(interRecommendationId));
  684. newTaskInfo.setInterRecommendation(personInfo);
  685. } catch (BOSException var22) {
  686. logger.error("******************设置智能导入所选内部推荐人失败!*****************");
  687. logger.error(var22.getMessage(), var22);
  688. }
  689. }
  690. if (StringUtils.isNotEmpty(sourceType)) {
  691. try {
  692. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseSourceType(
  693. new ObjectUuidPK(newTaskInfo.getId().toString()), sourceType);
  694. newTaskInfo.setSourceType(ResumeSourceType.getEnum(Integer.parseInt(sourceType)));
  695. } catch (BOSException var21) {
  696. logger.error("******************设置智能导入所选内部推荐人失败!*****************");
  697. logger.error(var21.getMessage(), var21);
  698. }
  699. }
  700. SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
  701. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
  702. .get("detailColl");
  703. Iterator entity;
  704. if (!RecBaseUtils.isEmpty(detailColl)) {
  705. entity = detailColl.iterator();
  706. SmartImportTaskDetailInfo detailInfo = null;
  707. while (entity.hasNext()) {
  708. detailInfo = (SmartImportTaskDetailInfo) entity.next();
  709. if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
  710. && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState()) && !detailInfo.isIsDelete()) {
  711. SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
  712. newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
  713. newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
  714. newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
  715. newDetailInfo.setTaskState(TaskStateEnum.SAVED);
  716. newDetailInfo.setTask(newTaskInfo);
  717. newDetailColl.add(newDetailInfo);
  718. try {
  719. SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
  720. } catch (EASBizException var19) {
  721. logger.error(var19.getMessage(), var19);
  722. throw new ShrWebBizException("保存任务详情失败!");
  723. } catch (BOSException var20) {
  724. logger.error(var20.getMessage(), var20);
  725. throw new ShrWebBizException("保存任务详情失败!");
  726. }
  727. }
  728. }
  729. }
  730. if (newTaskInfo != null) {
  731. newTaskInfo.put("detailColl", newDetailColl);
  732. }
  733. try {
  734. SmartImportTaskEntity entity1;
  735. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
  736. entity1 = new SmartImportTaskEntity(newTaskInfo, new RecommendResumeSmartImportImpl(
  737. recuritmentDemandId, interRecommendationId, sourceType));
  738. } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
  739. entity1 = new SmartImportTaskEntity(newTaskInfo, new ResumeSmartImportImpl(ctx,
  740. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  741. } else {
  742. entity1 = new SmartImportTaskEntity(newTaskInfo, new ArchiveSmartImportImpl(ctx,
  743. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  744. }
  745. this.submitTask(entity1);
  746. } catch (BOSException var18) {
  747. logger.error(var18.getMessage(), var18);
  748. throw new ShrWebBizException();
  749. }
  750. return this.getSmartImportTaskSchedule(newTaskInfo);
  751. }
  752. }
  753. }
  754. private void checkInfo(String recuritmentDemandId, String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
  755. if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
  756. if (StringUtils.isBlank(recuritmentDemandId)) {
  757. throw new ShrWebBizException("请选择简历夹!");
  758. }
  759. } else if (StringUtils.isBlank(recuritmentDemandId)) {
  760. throw new ShrWebBizException("请选择招聘需求!");
  761. }
  762. if (StringUtils.isBlank(taskId)) {
  763. throw new ShrWebBizException("解析任务ID不能为空!");
  764. }
  765. }
  766. /** @deprecated */
  767. @Deprecated
  768. public void archiveSmartImport(String resumeClipId, String taskId) throws ShrWebBizException {
  769. if (StringUtils.isBlank(resumeClipId)) {
  770. throw new ShrWebBizException("请选择目标简历夹!");
  771. } else if (StringUtils.isBlank(taskId)) {
  772. throw new ShrWebBizException("解析任务ID不能为空!");
  773. } else {
  774. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  775. Context ctx = SHRContext.getInstance().getContext();
  776. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  777. TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  778. if (runningTask != null) {
  779. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  780. } else {
  781. SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
  782. if (task == null) {
  783. throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
  784. } else {
  785. try {
  786. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  787. new ObjectUuidPK(task.getId()), new ObjectUuidPK(resumeClipId));
  788. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  789. resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
  790. task.setResumeClip(resumeClip);
  791. } catch (BOSException var10) {
  792. logger.error("******************设置智能导入所选简历夹失败!*****************");
  793. logger.error(var10.getMessage(), var10);
  794. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  795. }
  796. try {
  797. SmartImportTaskEntity entity = new SmartImportTaskEntity(task,
  798. new ArchiveSmartImportImpl(resumeClipId));
  799. this.submitTask(entity);
  800. } catch (BOSException var9) {
  801. logger.error(var9.getMessage(), var9);
  802. throw new ShrWebBizException(var9.getMessage());
  803. }
  804. }
  805. }
  806. }
  807. }
  808. /** @deprecated */
  809. @Deprecated
  810. public SmartImportTask archiveSmartImportAgain(String taskId) throws ShrWebBizException {
  811. if (StringUtils.isBlank(taskId)) {
  812. throw new ShrWebBizException("解析任务ID不能为空!");
  813. } else {
  814. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  815. Context ctx = SHRContext.getInstance().getContext();
  816. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  817. TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  818. if (runningTask != null) {
  819. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  820. } else {
  821. SmartImportTaskInfo taskInfo = null;
  822. try {
  823. taskInfo = SmartImportTaskFactory.getRemoteInstance().getSmartImportTaskSchedule(
  824. new ObjectUuidPK(user.getId()), TaskTypeEnum.SMARTIMPORT_ARCHIVE, taskId);
  825. } catch (BOSException var19) {
  826. logger.error(var19.getMessage(), var19);
  827. throw new ShrWebBizException("获取解析任务失败!");
  828. }
  829. String resumeClipId = taskInfo.getResumeClip().getId().toString();
  830. SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  831. try {
  832. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  833. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeClipId));
  834. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  835. resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
  836. newTaskInfo.setResumeClip(resumeClip);
  837. } catch (BOSException var18) {
  838. logger.error("******************设置智能导入所选简历夹失败!*****************");
  839. logger.error(var18.getMessage(), var18);
  840. throw new ShrWebBizException("设置导入简历夹失败!");
  841. }
  842. SmartImportTask newTask = new SmartImportTask(newTaskInfo);
  843. SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
  844. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
  845. .get("detailColl");
  846. if (!RecBaseUtils.isEmpty(detailColl)) {
  847. Iterator<SmartImportTaskDetailInfo> iter = detailColl.iterator();
  848. SmartImportTaskDetailInfo detailInfo = null;
  849. while (iter.hasNext()) {
  850. detailInfo = (SmartImportTaskDetailInfo) iter.next();
  851. if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
  852. && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
  853. SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
  854. newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
  855. newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
  856. newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
  857. newDetailInfo.setTaskState(TaskStateEnum.SAVED);
  858. newDetailInfo.setTask(newTaskInfo);
  859. newDetailColl.add(newDetailInfo);
  860. try {
  861. SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
  862. } catch (EASBizException var16) {
  863. logger.error(var16.getMessage(), var16);
  864. throw new ShrWebBizException("保存任务详情失败!");
  865. } catch (BOSException var17) {
  866. logger.error(var17.getMessage(), var17);
  867. throw new ShrWebBizException("保存任务详情失败!");
  868. }
  869. newTask.addNonExecuteTaskDetail(newDetailInfo);
  870. newTask.addTaskDetail(newDetailInfo);
  871. }
  872. }
  873. }
  874. newTask.setNonExecuteAmount(newDetailColl.size());
  875. newTask.setDoneAmount(0);
  876. newTask.setFailedAmount(0);
  877. newTask.setSuccessedAmount(0);
  878. newTask.setResumeAmount(newDetailColl.size());
  879. try {
  880. SmartImportTaskEntity entity = new SmartImportTaskEntity(newTaskInfo,
  881. new ArchiveSmartImportImpl(resumeClipId));
  882. this.submitTask(entity);
  883. return newTask;
  884. } catch (BOSException var15) {
  885. logger.error(var15.getMessage(), var15);
  886. throw new ShrWebBizException();
  887. }
  888. }
  889. }
  890. }
  891. private void submitTask(SmartImportTaskEntity taskEntity) throws ShrWebBizException {
  892. SmartImportTaskInfo task = taskEntity.getTaskInfo();
  893. try {
  894. SmartImportTaskFactory.getLocalInstance(taskEntity.getCtx()).taskSubmit(task);
  895. } catch (BOSException var4) {
  896. logger.error(var4.getMessage(), var4);
  897. throw new ShrWebBizException("任务提交异常,请稍后重试!");
  898. }
  899. Future future = RecSyncTaskThreadPool.getInstance().submitAsyncTask(taskEntity);
  900. this.afterSubmitTask(taskEntity, future);
  901. }
  902. private void afterSubmitTask(SmartImportTaskEntity taskEntity, Future future) {
  903. FutureTimeTask futureTimeTask = new FutureTimeTask(taskEntity, future);
  904. try {
  905. this.futureTaskQueue.put(futureTimeTask);
  906. } catch (InterruptedException var5) {
  907. logger.error("****************向添加超时任务队列添加任务失败!*****************");
  908. logger.error(var5.getMessage(), var5);
  909. }
  910. }
  911. public SmartImportTask getResumeSmartImportTaskSchedule(Context ctx, TaskTypeEnum taskType)
  912. throws ShrWebBizException {
  913. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  914. return this.getSmartImportTaskSchedule(ctx, user.getId().toString(), taskType);
  915. }
  916. private SmartImportTask getSmartImportTaskSchedule(SmartImportTaskInfo taskInfo) {
  917. SmartImportTask task = null;
  918. if (taskInfo != null) {
  919. task = new SmartImportTask(taskInfo);
  920. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo.get("detailColl");
  921. if (!RecBaseUtils.isEmpty(detailColl)) {
  922. int i = 0;
  923. for (int size = detailColl.size(); i < size; ++i) {
  924. SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
  925. if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
  926. task.addSuccessTaskDetail(detailInfo);
  927. } else if (TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
  928. task.addNonExecuteTaskDetail(detailInfo);
  929. } else {
  930. task.addFailTaskDetail(detailInfo);
  931. }
  932. task.addTaskDetail(detailInfo);
  933. }
  934. task.setNonExecuteAmount(task.getNonExecuteDetails().size());
  935. task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  936. task.setFailedAmount(task.getFailDetails().size());
  937. task.setSuccessedAmount(task.getSuccessDetails().size());
  938. task.setResumeAmount(task.getDetails().size());
  939. }
  940. }
  941. return task;
  942. }
  943. private SmartImportTask getSmartImportTaskSchedule(Context ctx, String userId, TaskTypeEnum taskType)
  944. throws ShrWebBizException {
  945. SmartImportTaskInfo taskInfo = this.getRunningTask(ctx, userId, taskType);
  946. if (taskInfo != null) {
  947. SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
  948. taskInfo.put("detailColl", detailColl);
  949. return this.getSmartImportTaskSchedule(taskInfo);
  950. } else {
  951. taskInfo = this.getLastEndTask(ctx, userId, taskType);
  952. if (taskInfo != null) {
  953. SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
  954. SmartImportTaskDetailCollection detailColl;
  955. SmartImportTask task;
  956. if (savedTaskInfo != null) {
  957. detailColl = this.getTaskDetailCollection(ctx, savedTaskInfo.getId().toString());
  958. savedTaskInfo.put("detailColl", detailColl);
  959. task = this.getSmartImportTaskSchedule(savedTaskInfo);
  960. } else {
  961. task = new SmartImportTask();
  962. }
  963. task.setLastTaskInfo(taskInfo);
  964. detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
  965. int i = 0;
  966. for (int size = detailColl.size(); i < size; ++i) {
  967. SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
  968. if (!detailInfo.isIsDelete()) {
  969. if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
  970. task.addSuccessTaskDetail(detailInfo);
  971. } else {
  972. task.addFailTaskDetail(detailInfo);
  973. }
  974. task.addTaskDetail(detailInfo);
  975. }
  976. }
  977. task.setFailedAmount(task.getFailDetails().size());
  978. task.setSuccessedAmount(task.getSuccessDetails().size());
  979. task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  980. task.setResumeAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  981. return task;
  982. } else {
  983. SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
  984. if (savedTaskInfo != null) {
  985. SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx,
  986. savedTaskInfo.getId().toString());
  987. savedTaskInfo.put("detailColl", detailColl);
  988. return this.getSmartImportTaskSchedule(savedTaskInfo);
  989. } else {
  990. return null;
  991. }
  992. }
  993. }
  994. }
  995. private SmartImportTaskInfo getLastSavedTask(Context ctx, String userId, TaskTypeEnum taskType)
  996. throws ShrWebBizException {
  997. SmartImportTaskInfo taskInfo = null;
  998. EntityViewInfo view = new EntityViewInfo();
  999. FilterInfo filter = new FilterInfo();
  1000. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  1001. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  1002. filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.EQUALS));
  1003. view.setFilter(filter);
  1004. SorterItemCollection sorterColl = new SorterItemCollection();
  1005. SorterItemInfo sorterItemInfo = new SorterItemInfo("createTime");
  1006. sorterItemInfo.setSortType(SortType.DESCEND);
  1007. sorterColl.add(sorterItemInfo);
  1008. view.setSorter(sorterColl);
  1009. SelectorItemCollection selector = new SelectorItemCollection();
  1010. selector.add("*");
  1011. selector.add("recDemand.*");
  1012. selector.add("interRecommendation.*");
  1013. selector.add("resumeSource.*");
  1014. selector.add("recDemand.recuritPosition.*");
  1015. selector.add("recDemand.hrJob.*");
  1016. selector.add("resumeClip.*");
  1017. view.setSelector(selector);
  1018. try {
  1019. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1020. .getSmartImportTaskCollection(view);
  1021. if (!RecDBUtils.isEmpty(taskColl)) {
  1022. taskInfo = taskColl.get(0);
  1023. }
  1024. return taskInfo;
  1025. } catch (BOSException var12) {
  1026. logger.error(var12.getMessage(), var12);
  1027. throw new ShrWebBizException("获取解析任务失败");
  1028. }
  1029. }
  1030. private SmartImportTaskInfo getRunningTask(Context ctx, String userId, TaskTypeEnum taskType)
  1031. throws ShrWebBizException {
  1032. SmartImportTaskInfo taskInfo = null;
  1033. EntityViewInfo view = new EntityViewInfo();
  1034. FilterInfo filter = new FilterInfo();
  1035. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  1036. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  1037. filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.NOTEQUALS));
  1038. filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.NOTEQUALS));
  1039. filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.NOTEQUALS));
  1040. filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.NOTEQUALS));
  1041. filter.getFilterItems().add(new FilterItemInfo("taskState", 9, CompareType.NOTEQUALS));
  1042. view.setFilter(filter);
  1043. SorterItemCollection sorterColl = new SorterItemCollection();
  1044. SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
  1045. sorterItemInfo.setSortType(SortType.DESCEND);
  1046. sorterColl.add(sorterItemInfo);
  1047. view.setSorter(sorterColl);
  1048. SelectorItemCollection selector = new SelectorItemCollection();
  1049. selector.add("*");
  1050. selector.add("recDemand.*");
  1051. selector.add("interRecommendation.*");
  1052. selector.add("resumeSource.*");
  1053. selector.add("recDemand.recuritPosition.*");
  1054. selector.add("recDemand.hrJob.*");
  1055. selector.add("resumeClip.*");
  1056. view.setSelector(selector);
  1057. try {
  1058. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1059. .getSmartImportTaskCollection(view);
  1060. if (!RecDBUtils.isEmpty(taskColl)) {
  1061. taskInfo = taskColl.get(0);
  1062. }
  1063. return taskInfo;
  1064. } catch (BOSException var12) {
  1065. logger.error(var12.getMessage(), var12);
  1066. throw new ShrWebBizException("获取正在运行中的解析任务失败");
  1067. }
  1068. }
  1069. private SmartImportTaskInfo getLastEndTask(Context ctx, String userId, TaskTypeEnum taskType)
  1070. throws ShrWebBizException {
  1071. SmartImportTaskInfo taskInfo = null;
  1072. EntityViewInfo view = new EntityViewInfo();
  1073. FilterInfo filter = new FilterInfo();
  1074. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  1075. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  1076. filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.EQUALS));
  1077. filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.EQUALS));
  1078. filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.EQUALS));
  1079. filter.setMaskString("#0 and #1 and (#2 or #3 or #4)");
  1080. view.setFilter(filter);
  1081. SorterItemCollection sorterColl = new SorterItemCollection();
  1082. SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
  1083. sorterItemInfo.setSortType(SortType.DESCEND);
  1084. sorterColl.add(sorterItemInfo);
  1085. view.setSorter(sorterColl);
  1086. SelectorItemCollection selector = new SelectorItemCollection();
  1087. selector.add("*");
  1088. selector.add("recDemand.*");
  1089. selector.add("interRecommendation.*");
  1090. selector.add("resumeSource.*");
  1091. selector.add("recDemand.recuritPosition.*");
  1092. selector.add("recDemand.hrJob.*");
  1093. selector.add("resumeClip.*");
  1094. view.setSelector(selector);
  1095. try {
  1096. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1097. .getSmartImportTaskCollection(view);
  1098. if (!RecDBUtils.isEmpty(taskColl)) {
  1099. taskInfo = taskColl.get(0);
  1100. }
  1101. return taskInfo;
  1102. } catch (BOSException var12) {
  1103. logger.error(var12.getMessage(), var12);
  1104. throw new ShrWebBizException("获取解析任务失败");
  1105. }
  1106. }
  1107. private SmartImportTaskDetailCollection getTaskDetailCollection(Context ctx, String taskId)
  1108. throws ShrWebBizException {
  1109. EntityViewInfo evi = new EntityViewInfo();
  1110. FilterInfo filter01 = new FilterInfo();
  1111. filter01.getFilterItems().add(new FilterItemInfo("task", taskId, CompareType.EQUALS));
  1112. evi.setFilter(filter01);
  1113. SelectorItemCollection selectorColl01 = evi.getSelector();
  1114. selectorColl01.add(new SelectorItemInfo("id"));
  1115. selectorColl01.add(new SelectorItemInfo("resumeFileName"));
  1116. selectorColl01.add(new SelectorItemInfo("resumeFileType"));
  1117. selectorColl01.add(new SelectorItemInfo("taskState"));
  1118. selectorColl01.add(new SelectorItemInfo("info"));
  1119. selectorColl01.add(new SelectorItemInfo("task"));
  1120. selectorColl01.add(new SelectorItemInfo("isDelete"));
  1121. SmartImportTaskDetailCollection detailColl = null;
  1122. try {
  1123. detailColl = SmartImportTaskDetailFactory.getLocalInstance(ctx).getSmartImportTaskDetailCollection(evi);
  1124. return detailColl;
  1125. } catch (BOSException var8) {
  1126. logger.error(var8.getMessage(), var8);
  1127. throw new ShrWebBizException("获取任务详情失败");
  1128. }
  1129. }
  1130. public void affirmSmartImportTaskResult(String smartImportTaskId) throws ShrWebBizException {
  1131. try {
  1132. SmartImportTaskFactory.getRemoteInstance().affirmTask(new ObjectUuidPK(smartImportTaskId));
  1133. } catch (BOSException var3) {
  1134. logger.error(var3.getMessage(), var3);
  1135. throw new ShrWebBizException("确认失败,请重试!");
  1136. }
  1137. }
  1138. public void deleteResume(String taskDetailIds) throws ShrWebBizException {
  1139. if (StringUtils.isEmpty(taskDetailIds)) {
  1140. throw new ShrWebBizException("请选择要删除的简历!");
  1141. } else {
  1142. String[] detailAry = taskDetailIds.split(",");
  1143. try {
  1144. SmartImportTaskDetailFactory.getRemoteInstance().deleteResumes(detailAry);
  1145. } catch (BOSException var4) {
  1146. logger.error(var4.getMessage(), var4);
  1147. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  1148. }
  1149. }
  1150. }
  1151. public void updateResume(Map<String, MultipartFile> fileMap, String resumeId, TaskTypeEnum taskType)
  1152. throws ShrWebBizException {
  1153. if (StringUtils.isEmpty(resumeId)) {
  1154. throw new ShrWebBizException("简历更新失败,resumeId为空!");
  1155. } else {
  1156. Context ctx = SHRContext.getInstance().getContext();
  1157. Iterator var5 = fileMap.entrySet().iterator();
  1158. while (true) {
  1159. if (var5.hasNext()) {
  1160. Map.Entry<String, MultipartFile> entity = (Map.Entry) var5.next();
  1161. MultipartFile mf = (MultipartFile) entity.getValue();
  1162. FileSafeUtil.checkFileCompliance(ctx, mf, FILETYPELIST, "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF");
  1163. String resumeFileName = mf.getOriginalFilename();
  1164. byte[] resumeFileData = null;
  1165. try {
  1166. resumeFileData = mf.getBytes();
  1167. } catch (IOException var12) {
  1168. logger.error(var12.getMessage(), var12);
  1169. throw new ShrWebBizException("附件上传失败,获取附件内容异常!");
  1170. }
  1171. if (StringUtils.isBlank(resumeFileName)) {
  1172. throw new ShrWebBizException("简历附件名不能为空:" + resumeFileName);
  1173. }
  1174. if (resumeFileData != null && resumeFileData.length >= this.resumeFileMinSize) {
  1175. if (resumeFileData.length > this.resumeFileMaxSize) {
  1176. throw new ShrWebBizException("简历附件大小不能超过:" + this.resumeFileMaxSize / 1024 / 1024 + "M!");
  1177. }
  1178. try {
  1179. boolean result = SmartResumeUpdateService.getInstance().smartResumeUpdate(ctx, mf, resumeId,
  1180. taskType);
  1181. if (!result) {
  1182. throw new ShrWebBizException("简历更新失败,请联系系统管理员!");
  1183. }
  1184. continue;
  1185. } catch (BOSException var11) {
  1186. logger.error(var11.getMessage(), var11);
  1187. throw new ShrWebBizException(var11.getMessage());
  1188. }
  1189. }
  1190. throw new ShrWebBizException("简历附件不能为空!");
  1191. }
  1192. return;
  1193. }
  1194. }
  1195. }
  1196. public void recoverSmartImportTask(Context ctx) throws BOSException {
  1197. if (logger.isDebugEnabled()) {
  1198. logger.debug("**********启动智能导入恢复任务recoverSmartImportTask**********");
  1199. }
  1200. Calendar c = Calendar.getInstance();
  1201. c.add(12, -35);
  1202. Date timeout = c.getTime();
  1203. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  1204. String timeoutStr = sdf.format(timeout);
  1205. SmartImportTaskCollection taskColl = null;
  1206. try {
  1207. taskColl = SmartImportTaskFactory.getLocalInstance(ctx).getSmartImportTaskCollection(
  1208. "where taskState = 9 or ((taskState = 4 or taskState = 2) and taskStartDate <= {ts'" + timeoutStr
  1209. + "'})");
  1210. } catch (BOSException var11) {
  1211. logger.error("*************************************获取超时及异常任务失败!*************************************");
  1212. logger.error(var11.getMessage(), var11);
  1213. }
  1214. if (!RecBaseUtils.isEmpty(taskColl)) {
  1215. Iterator<SmartImportTaskInfo> iter = taskColl.iterator();
  1216. SmartImportTaskInfo taskInfo = null;
  1217. while (iter.hasNext()) {
  1218. taskInfo = (SmartImportTaskInfo) iter.next();
  1219. try {
  1220. SmartImportTaskEntity TaskEntity = null;
  1221. if (TaskTypeEnum.SMARTIMPORT_RESUME.equals(taskInfo.getTaskType())) {
  1222. TaskEntity = new SmartImportTaskEntity(taskInfo, new ResumeSmartImportImpl(ctx,
  1223. taskInfo.getRecDemand().getId().toString(),
  1224. taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
  1225. taskInfo.getInterRecommendation() == null ? ""
  1226. : taskInfo.getInterRecommendation().getId().toString(),
  1227. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1228. } else if (TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME.equals(taskInfo.getTaskType())) {
  1229. TaskEntity = new SmartImportTaskEntity(taskInfo,
  1230. new RecommendResumeSmartImportImpl(taskInfo.getRecDemand().getId().toString(),
  1231. taskInfo.getInterRecommendation() == null ? ""
  1232. : taskInfo.getInterRecommendation().getId().toString(),
  1233. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1234. } else {
  1235. TaskEntity = new SmartImportTaskEntity(taskInfo, new ArchiveSmartImportImpl(ctx,
  1236. taskInfo.getResumeClip().getId().toString(),
  1237. taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
  1238. taskInfo.getInterRecommendation() == null ? ""
  1239. : taskInfo.getInterRecommendation().getId().toString(),
  1240. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1241. }
  1242. if (TaskEntity != null) {
  1243. this.submitTask(TaskEntity);
  1244. }
  1245. } catch (ShrWebBizException var10) {
  1246. logger.error("*******************恢复" + taskInfo.getId() + "任务失败!*******************");
  1247. logger.error(var10.getMessage(), var10);
  1248. }
  1249. }
  1250. } else if (logger.isDebugEnabled()) {
  1251. logger.debug("*************************************不存在超时及异常任务!*************************************");
  1252. }
  1253. }
  1254. private class TimeoutTaskCheckThread implements Runnable {
  1255. private TimeoutTaskCheckThread() {
  1256. }
  1257. public void run() {
  1258. if (SmartImportServiceEx.logger.isDebugEnabled()) {
  1259. SmartImportServiceEx.logger.debug("**************超时任务监控线程启动**************");
  1260. }
  1261. while (!Thread.currentThread().isInterrupted()) {
  1262. try {
  1263. FutureTimeTask future = (FutureTimeTask) SmartImportServiceEx.this.futureTaskQueue.take();
  1264. if (!future.timeoutCancel()) {
  1265. SmartImportServiceEx.this.futureTaskQueue.put(future);
  1266. }
  1267. Thread.sleep(100L);
  1268. } catch (InterruptedException var2) {
  1269. SmartImportServiceEx.logger.error("************************超时任务队列获取数据被异常中断***********************");
  1270. SmartImportServiceEx.logger.error(var2.getMessage(), var2);
  1271. } catch (Exception var3) {
  1272. SmartImportServiceEx.logger.error("************************超时任务队列获取数据异常***********************");
  1273. SmartImportServiceEx.logger.error(var3.getMessage(), var3);
  1274. }
  1275. }
  1276. if (SmartImportServiceEx.logger.isDebugEnabled()) {
  1277. SmartImportServiceEx.logger.debug("**************超时任务监控线程中断**************");
  1278. }
  1279. }
  1280. }
  1281. private class FutureTimeTask {
  1282. private Future future;
  1283. private SmartImportTaskEntity taskEntity;
  1284. public FutureTimeTask(SmartImportTaskEntity taskEntity, Future future) {
  1285. this.taskEntity = taskEntity;
  1286. this.future = future;
  1287. }
  1288. public boolean timeoutCancel() {
  1289. SmartImportTaskInfo taskInfo = this.taskEntity.getTaskInfo();
  1290. if (taskInfo.getTaskState().equals(TaskStateEnum.RUNNING)) {
  1291. if (!this.future.isDone()) {
  1292. long now = System.currentTimeMillis();
  1293. if (now - taskInfo.getTaskStartDate().getTime() <= SmartImportServiceEx.this.taskTimeoutMillis) {
  1294. return false;
  1295. }
  1296. this.future.cancel(true);
  1297. }
  1298. } else if (taskInfo.getTaskState().equals(TaskStateEnum.SUBMITED)) {
  1299. return false;
  1300. }
  1301. return true;
  1302. }
  1303. }
  1304. private static class SmartImportServiceHolder {
  1305. private static final SmartImportServiceEx service = new SmartImportServiceEx();
  1306. private SmartImportServiceHolder() {
  1307. }
  1308. }
  1309. }