SmartImportServiceEx.java 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467
  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. task.put("isKeyTalent", paraMap.get("isKeyTalent"));
  576. }
  577. // 电话号码
  578. if (paraMap.containsKey("phoneModify")) {
  579. task.put("phoneModify", paraMap.get("phoneModify"));
  580. }
  581. // over
  582. try {
  583. SmartImportTaskEntity entity1;
  584. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
  585. entity1 = new SmartImportTaskEntity(task, new RecommendResumeSmartImportImpl(
  586. recuritmentDemandId, interRecommendationId, sourceType));
  587. } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
  588. entity1 = new SmartImportTaskEntity(task, new ResumeSmartImportImpl(ctx, recuritmentDemandId,
  589. resumeSourceId, interRecommendationId, sourceType));
  590. } else {
  591. entity1 = new SmartImportTaskEntity(task, new ArchiveSmartImportImpl(ctx,
  592. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  593. }
  594. this.submitTask(entity1);
  595. } catch (BOSException var12) {
  596. logger.error(var12.getMessage(), var12);
  597. throw new ShrWebBizException();
  598. }
  599. }
  600. }
  601. }
  602. }
  603. public SmartImportTask resumeSmartImportAgain(String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
  604. if (StringUtils.isBlank(taskId)) {
  605. throw new ShrWebBizException("解析任务ID不能为空!");
  606. } else {
  607. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  608. Context ctx = SHRContext.getInstance().getContext();
  609. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(), taskType);
  610. if (runningTask != null) {
  611. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  612. } else {
  613. SmartImportTaskInfo taskInfo = null;
  614. try {
  615. taskInfo = SmartImportTaskFactory.getRemoteInstance()
  616. .getSmartImportTaskSchedule(new ObjectUuidPK(user.getId()), taskType, taskId);
  617. } catch (BOSException var26) {
  618. logger.error(var26.getMessage(), var26);
  619. throw new ShrWebBizException("获取解析任务失败!");
  620. }
  621. String recuritmentDemandId = taskInfo.getRecDemand().getId().toString();
  622. String interRecommendationId = "";
  623. if (null != taskInfo.getInterRecommendation()) {
  624. interRecommendationId = taskInfo.getInterRecommendation().getId().toString();
  625. }
  626. String resumeSourceId = "";
  627. if (null != taskInfo.getResumeSource()) {
  628. resumeSourceId = taskInfo.getResumeSource().getId().toString();
  629. }
  630. String sourceType = "";
  631. if (null != taskInfo.getSourceType()) {
  632. sourceType = taskInfo.getSourceType().getValue() + "";
  633. }
  634. SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, taskType);
  635. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_ARCHIVE)) {
  636. try {
  637. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  638. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
  639. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  640. resumeClip.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  641. newTaskInfo.setResumeClip(resumeClip);
  642. } catch (BOSException var25) {
  643. logger.error("******************设置智能导入所选简历夹失败!*****************");
  644. logger.error(var25.getMessage(), var25);
  645. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  646. }
  647. } else {
  648. try {
  649. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseDemand(
  650. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(recuritmentDemandId));
  651. RecuritmentDemandInfo recDemandInfo = new RecuritmentDemandInfo();
  652. recDemandInfo.setId((new ObjectUuidPK(recuritmentDemandId)).getKeyValue());
  653. newTaskInfo.setRecDemand(recDemandInfo);
  654. } catch (BOSException var24) {
  655. logger.error("******************设置智能导入所选需求失败!*****************");
  656. logger.error(var24.getMessage(), var24);
  657. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  658. }
  659. }
  660. if (StringUtils.isNotEmpty(resumeSourceId)) {
  661. try {
  662. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeSource(
  663. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeSourceId));
  664. ResumeSourceInfo resumeSourceInfo = new ResumeSourceInfo();
  665. resumeSourceInfo.setId(BOSUuid.read(resumeSourceId));
  666. newTaskInfo.setResumeSource(resumeSourceInfo);
  667. } catch (BOSException var23) {
  668. logger.error("******************设置智能导入简历来源失败!*****************");
  669. logger.error(var23.getMessage(), var23);
  670. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  671. }
  672. }
  673. if (StringUtils.isNotEmpty(interRecommendationId)) {
  674. try {
  675. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseRecommendation(
  676. new ObjectUuidPK(newTaskInfo.getId().toString()),
  677. new ObjectUuidPK(interRecommendationId));
  678. PersonInfo personInfo = new PersonInfo();
  679. personInfo.setId(BOSUuid.read(interRecommendationId));
  680. newTaskInfo.setInterRecommendation(personInfo);
  681. } catch (BOSException var22) {
  682. logger.error("******************设置智能导入所选内部推荐人失败!*****************");
  683. logger.error(var22.getMessage(), var22);
  684. }
  685. }
  686. if (StringUtils.isNotEmpty(sourceType)) {
  687. try {
  688. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseSourceType(
  689. new ObjectUuidPK(newTaskInfo.getId().toString()), sourceType);
  690. newTaskInfo.setSourceType(ResumeSourceType.getEnum(Integer.parseInt(sourceType)));
  691. } catch (BOSException var21) {
  692. logger.error("******************设置智能导入所选内部推荐人失败!*****************");
  693. logger.error(var21.getMessage(), var21);
  694. }
  695. }
  696. SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
  697. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
  698. .get("detailColl");
  699. Iterator entity;
  700. if (!RecBaseUtils.isEmpty(detailColl)) {
  701. entity = detailColl.iterator();
  702. SmartImportTaskDetailInfo detailInfo = null;
  703. while (entity.hasNext()) {
  704. detailInfo = (SmartImportTaskDetailInfo) entity.next();
  705. if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
  706. && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState()) && !detailInfo.isIsDelete()) {
  707. SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
  708. newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
  709. newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
  710. newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
  711. newDetailInfo.setTaskState(TaskStateEnum.SAVED);
  712. newDetailInfo.setTask(newTaskInfo);
  713. newDetailColl.add(newDetailInfo);
  714. try {
  715. SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
  716. } catch (EASBizException var19) {
  717. logger.error(var19.getMessage(), var19);
  718. throw new ShrWebBizException("保存任务详情失败!");
  719. } catch (BOSException var20) {
  720. logger.error(var20.getMessage(), var20);
  721. throw new ShrWebBizException("保存任务详情失败!");
  722. }
  723. }
  724. }
  725. }
  726. if (newTaskInfo != null) {
  727. newTaskInfo.put("detailColl", newDetailColl);
  728. }
  729. try {
  730. SmartImportTaskEntity entity1;
  731. if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME)) {
  732. entity1 = new SmartImportTaskEntity(newTaskInfo, new RecommendResumeSmartImportImpl(
  733. recuritmentDemandId, interRecommendationId, sourceType));
  734. } else if (taskType.equals(TaskTypeEnum.SMARTIMPORT_RESUME)) {
  735. entity1 = new SmartImportTaskEntity(newTaskInfo, new ResumeSmartImportImpl(ctx,
  736. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  737. } else {
  738. entity1 = new SmartImportTaskEntity(newTaskInfo, new ArchiveSmartImportImpl(ctx,
  739. recuritmentDemandId, resumeSourceId, interRecommendationId, sourceType));
  740. }
  741. this.submitTask(entity1);
  742. } catch (BOSException var18) {
  743. logger.error(var18.getMessage(), var18);
  744. throw new ShrWebBizException();
  745. }
  746. return this.getSmartImportTaskSchedule(newTaskInfo);
  747. }
  748. }
  749. }
  750. private void checkInfo(String recuritmentDemandId, String taskId, TaskTypeEnum taskType) throws ShrWebBizException {
  751. if (taskType.equals(TaskTypeEnum.SELF_ENTERPRISEARCHIVES)) {
  752. if (StringUtils.isBlank(recuritmentDemandId)) {
  753. throw new ShrWebBizException("请选择简历夹!");
  754. }
  755. } else if (StringUtils.isBlank(recuritmentDemandId)) {
  756. throw new ShrWebBizException("请选择招聘需求!");
  757. }
  758. if (StringUtils.isBlank(taskId)) {
  759. throw new ShrWebBizException("解析任务ID不能为空!");
  760. }
  761. }
  762. /** @deprecated */
  763. @Deprecated
  764. public void archiveSmartImport(String resumeClipId, String taskId) throws ShrWebBizException {
  765. if (StringUtils.isBlank(resumeClipId)) {
  766. throw new ShrWebBizException("请选择目标简历夹!");
  767. } else if (StringUtils.isBlank(taskId)) {
  768. throw new ShrWebBizException("解析任务ID不能为空!");
  769. } else {
  770. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  771. Context ctx = SHRContext.getInstance().getContext();
  772. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  773. TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  774. if (runningTask != null) {
  775. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  776. } else {
  777. SmartImportTaskInfo task = this.getSmartImportTaskById(taskId);
  778. if (task == null) {
  779. throw new ShrWebBizException("获取用户智能导入任务失败,请刷新重试!");
  780. } else {
  781. try {
  782. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  783. new ObjectUuidPK(task.getId()), new ObjectUuidPK(resumeClipId));
  784. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  785. resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
  786. task.setResumeClip(resumeClip);
  787. } catch (BOSException var10) {
  788. logger.error("******************设置智能导入所选简历夹失败!*****************");
  789. logger.error(var10.getMessage(), var10);
  790. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  791. }
  792. try {
  793. SmartImportTaskEntity entity = new SmartImportTaskEntity(task,
  794. new ArchiveSmartImportImpl(resumeClipId));
  795. this.submitTask(entity);
  796. } catch (BOSException var9) {
  797. logger.error(var9.getMessage(), var9);
  798. throw new ShrWebBizException(var9.getMessage());
  799. }
  800. }
  801. }
  802. }
  803. }
  804. /** @deprecated */
  805. @Deprecated
  806. public SmartImportTask archiveSmartImportAgain(String taskId) throws ShrWebBizException {
  807. if (StringUtils.isBlank(taskId)) {
  808. throw new ShrWebBizException("解析任务ID不能为空!");
  809. } else {
  810. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  811. Context ctx = SHRContext.getInstance().getContext();
  812. SmartImportTaskInfo runningTask = this.getRunningTask(ctx, user.getId().toString(),
  813. TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  814. if (runningTask != null) {
  815. throw new ShrWebBizException("您当前存在正在运行的任务,请稍后重试!");
  816. } else {
  817. SmartImportTaskInfo taskInfo = null;
  818. try {
  819. taskInfo = SmartImportTaskFactory.getRemoteInstance().getSmartImportTaskSchedule(
  820. new ObjectUuidPK(user.getId()), TaskTypeEnum.SMARTIMPORT_ARCHIVE, taskId);
  821. } catch (BOSException var19) {
  822. logger.error(var19.getMessage(), var19);
  823. throw new ShrWebBizException("获取解析任务失败!");
  824. }
  825. String resumeClipId = taskInfo.getResumeClip().getId().toString();
  826. SmartImportTaskInfo newTaskInfo = this.addUserProgressTask(user, TaskTypeEnum.SMARTIMPORT_ARCHIVE);
  827. try {
  828. SmartImportTaskFactory.getRemoteInstance().setSmartImportChooseResumeClip(
  829. new ObjectUuidPK(newTaskInfo.getId()), new ObjectUuidPK(resumeClipId));
  830. ResumeClipBaseInfo resumeClip = new ResumeClipBaseInfo();
  831. resumeClip.setId((new ObjectUuidPK(resumeClipId)).getKeyValue());
  832. newTaskInfo.setResumeClip(resumeClip);
  833. } catch (BOSException var18) {
  834. logger.error("******************设置智能导入所选简历夹失败!*****************");
  835. logger.error(var18.getMessage(), var18);
  836. throw new ShrWebBizException("设置导入简历夹失败!");
  837. }
  838. SmartImportTask newTask = new SmartImportTask(newTaskInfo);
  839. SmartImportTaskDetailCollection newDetailColl = new SmartImportTaskDetailCollection();
  840. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo
  841. .get("detailColl");
  842. if (!RecBaseUtils.isEmpty(detailColl)) {
  843. Iterator<SmartImportTaskDetailInfo> iter = detailColl.iterator();
  844. SmartImportTaskDetailInfo detailInfo = null;
  845. while (iter.hasNext()) {
  846. detailInfo = (SmartImportTaskDetailInfo) iter.next();
  847. if (!TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())
  848. && !TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
  849. SmartImportTaskDetailInfo newDetailInfo = new SmartImportTaskDetailInfo();
  850. newDetailInfo.setResumeFileName(detailInfo.getResumeFileName());
  851. newDetailInfo.setResumeFileType(detailInfo.getResumeFileType());
  852. newDetailInfo.setResumeFileData(detailInfo.getResumeFileData());
  853. newDetailInfo.setTaskState(TaskStateEnum.SAVED);
  854. newDetailInfo.setTask(newTaskInfo);
  855. newDetailColl.add(newDetailInfo);
  856. try {
  857. SmartImportTaskDetailFactory.getRemoteInstance().addnew(newDetailInfo);
  858. } catch (EASBizException var16) {
  859. logger.error(var16.getMessage(), var16);
  860. throw new ShrWebBizException("保存任务详情失败!");
  861. } catch (BOSException var17) {
  862. logger.error(var17.getMessage(), var17);
  863. throw new ShrWebBizException("保存任务详情失败!");
  864. }
  865. newTask.addNonExecuteTaskDetail(newDetailInfo);
  866. newTask.addTaskDetail(newDetailInfo);
  867. }
  868. }
  869. }
  870. newTask.setNonExecuteAmount(newDetailColl.size());
  871. newTask.setDoneAmount(0);
  872. newTask.setFailedAmount(0);
  873. newTask.setSuccessedAmount(0);
  874. newTask.setResumeAmount(newDetailColl.size());
  875. try {
  876. SmartImportTaskEntity entity = new SmartImportTaskEntity(newTaskInfo,
  877. new ArchiveSmartImportImpl(resumeClipId));
  878. this.submitTask(entity);
  879. return newTask;
  880. } catch (BOSException var15) {
  881. logger.error(var15.getMessage(), var15);
  882. throw new ShrWebBizException();
  883. }
  884. }
  885. }
  886. }
  887. private void submitTask(SmartImportTaskEntity taskEntity) throws ShrWebBizException {
  888. SmartImportTaskInfo task = taskEntity.getTaskInfo();
  889. try {
  890. SmartImportTaskFactory.getLocalInstance(taskEntity.getCtx()).taskSubmit(task);
  891. } catch (BOSException var4) {
  892. logger.error(var4.getMessage(), var4);
  893. throw new ShrWebBizException("任务提交异常,请稍后重试!");
  894. }
  895. Future future = RecSyncTaskThreadPool.getInstance().submitAsyncTask(taskEntity);
  896. this.afterSubmitTask(taskEntity, future);
  897. }
  898. private void afterSubmitTask(SmartImportTaskEntity taskEntity, Future future) {
  899. FutureTimeTask futureTimeTask = new FutureTimeTask(taskEntity, future);
  900. try {
  901. this.futureTaskQueue.put(futureTimeTask);
  902. } catch (InterruptedException var5) {
  903. logger.error("****************向添加超时任务队列添加任务失败!*****************");
  904. logger.error(var5.getMessage(), var5);
  905. }
  906. }
  907. public SmartImportTask getResumeSmartImportTaskSchedule(Context ctx, TaskTypeEnum taskType)
  908. throws ShrWebBizException {
  909. UserInfo user = RecWebBaseUtils.getCurrentUserInfo();
  910. return this.getSmartImportTaskSchedule(ctx, user.getId().toString(), taskType);
  911. }
  912. private SmartImportTask getSmartImportTaskSchedule(SmartImportTaskInfo taskInfo) {
  913. SmartImportTask task = null;
  914. if (taskInfo != null) {
  915. task = new SmartImportTask(taskInfo);
  916. SmartImportTaskDetailCollection detailColl = (SmartImportTaskDetailCollection) taskInfo.get("detailColl");
  917. if (!RecBaseUtils.isEmpty(detailColl)) {
  918. int i = 0;
  919. for (int size = detailColl.size(); i < size; ++i) {
  920. SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
  921. if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
  922. task.addSuccessTaskDetail(detailInfo);
  923. } else if (TaskStateEnum.SAVED.equals(detailInfo.getTaskState())) {
  924. task.addNonExecuteTaskDetail(detailInfo);
  925. } else {
  926. task.addFailTaskDetail(detailInfo);
  927. }
  928. task.addTaskDetail(detailInfo);
  929. }
  930. task.setNonExecuteAmount(task.getNonExecuteDetails().size());
  931. task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  932. task.setFailedAmount(task.getFailDetails().size());
  933. task.setSuccessedAmount(task.getSuccessDetails().size());
  934. task.setResumeAmount(task.getDetails().size());
  935. }
  936. }
  937. return task;
  938. }
  939. private SmartImportTask getSmartImportTaskSchedule(Context ctx, String userId, TaskTypeEnum taskType)
  940. throws ShrWebBizException {
  941. SmartImportTaskInfo taskInfo = this.getRunningTask(ctx, userId, taskType);
  942. if (taskInfo != null) {
  943. SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
  944. taskInfo.put("detailColl", detailColl);
  945. return this.getSmartImportTaskSchedule(taskInfo);
  946. } else {
  947. taskInfo = this.getLastEndTask(ctx, userId, taskType);
  948. if (taskInfo != null) {
  949. SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
  950. SmartImportTaskDetailCollection detailColl;
  951. SmartImportTask task;
  952. if (savedTaskInfo != null) {
  953. detailColl = this.getTaskDetailCollection(ctx, savedTaskInfo.getId().toString());
  954. savedTaskInfo.put("detailColl", detailColl);
  955. task = this.getSmartImportTaskSchedule(savedTaskInfo);
  956. } else {
  957. task = new SmartImportTask();
  958. }
  959. task.setLastTaskInfo(taskInfo);
  960. detailColl = this.getTaskDetailCollection(ctx, taskInfo.getId().toString());
  961. int i = 0;
  962. for (int size = detailColl.size(); i < size; ++i) {
  963. SmartImportTaskDetailInfo detailInfo = detailColl.get(i);
  964. if (!detailInfo.isIsDelete()) {
  965. if (TaskStateEnum.FINISHED.equals(detailInfo.getTaskState())) {
  966. task.addSuccessTaskDetail(detailInfo);
  967. } else {
  968. task.addFailTaskDetail(detailInfo);
  969. }
  970. task.addTaskDetail(detailInfo);
  971. }
  972. }
  973. task.setFailedAmount(task.getFailDetails().size());
  974. task.setSuccessedAmount(task.getSuccessDetails().size());
  975. task.setDoneAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  976. task.setResumeAmount(task.getSuccessDetails().size() + task.getFailDetails().size());
  977. return task;
  978. } else {
  979. SmartImportTaskInfo savedTaskInfo = this.getLastSavedTask(ctx, userId, taskType);
  980. if (savedTaskInfo != null) {
  981. SmartImportTaskDetailCollection detailColl = this.getTaskDetailCollection(ctx,
  982. savedTaskInfo.getId().toString());
  983. savedTaskInfo.put("detailColl", detailColl);
  984. return this.getSmartImportTaskSchedule(savedTaskInfo);
  985. } else {
  986. return null;
  987. }
  988. }
  989. }
  990. }
  991. private SmartImportTaskInfo getLastSavedTask(Context ctx, String userId, TaskTypeEnum taskType)
  992. throws ShrWebBizException {
  993. SmartImportTaskInfo taskInfo = null;
  994. EntityViewInfo view = new EntityViewInfo();
  995. FilterInfo filter = new FilterInfo();
  996. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  997. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  998. filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.EQUALS));
  999. view.setFilter(filter);
  1000. SorterItemCollection sorterColl = new SorterItemCollection();
  1001. SorterItemInfo sorterItemInfo = new SorterItemInfo("createTime");
  1002. sorterItemInfo.setSortType(SortType.DESCEND);
  1003. sorterColl.add(sorterItemInfo);
  1004. view.setSorter(sorterColl);
  1005. SelectorItemCollection selector = new SelectorItemCollection();
  1006. selector.add("*");
  1007. selector.add("recDemand.*");
  1008. selector.add("interRecommendation.*");
  1009. selector.add("resumeSource.*");
  1010. selector.add("recDemand.recuritPosition.*");
  1011. selector.add("recDemand.hrJob.*");
  1012. selector.add("resumeClip.*");
  1013. view.setSelector(selector);
  1014. try {
  1015. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1016. .getSmartImportTaskCollection(view);
  1017. if (!RecDBUtils.isEmpty(taskColl)) {
  1018. taskInfo = taskColl.get(0);
  1019. }
  1020. return taskInfo;
  1021. } catch (BOSException var12) {
  1022. logger.error(var12.getMessage(), var12);
  1023. throw new ShrWebBizException("获取解析任务失败");
  1024. }
  1025. }
  1026. private SmartImportTaskInfo getRunningTask(Context ctx, String userId, TaskTypeEnum taskType)
  1027. throws ShrWebBizException {
  1028. SmartImportTaskInfo taskInfo = null;
  1029. EntityViewInfo view = new EntityViewInfo();
  1030. FilterInfo filter = new FilterInfo();
  1031. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  1032. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  1033. filter.getFilterItems().add(new FilterItemInfo("taskState", 1, CompareType.NOTEQUALS));
  1034. filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.NOTEQUALS));
  1035. filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.NOTEQUALS));
  1036. filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.NOTEQUALS));
  1037. filter.getFilterItems().add(new FilterItemInfo("taskState", 9, CompareType.NOTEQUALS));
  1038. view.setFilter(filter);
  1039. SorterItemCollection sorterColl = new SorterItemCollection();
  1040. SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
  1041. sorterItemInfo.setSortType(SortType.DESCEND);
  1042. sorterColl.add(sorterItemInfo);
  1043. view.setSorter(sorterColl);
  1044. SelectorItemCollection selector = new SelectorItemCollection();
  1045. selector.add("*");
  1046. selector.add("recDemand.*");
  1047. selector.add("interRecommendation.*");
  1048. selector.add("resumeSource.*");
  1049. selector.add("recDemand.recuritPosition.*");
  1050. selector.add("recDemand.hrJob.*");
  1051. selector.add("resumeClip.*");
  1052. view.setSelector(selector);
  1053. try {
  1054. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1055. .getSmartImportTaskCollection(view);
  1056. if (!RecDBUtils.isEmpty(taskColl)) {
  1057. taskInfo = taskColl.get(0);
  1058. }
  1059. return taskInfo;
  1060. } catch (BOSException var12) {
  1061. logger.error(var12.getMessage(), var12);
  1062. throw new ShrWebBizException("获取正在运行中的解析任务失败");
  1063. }
  1064. }
  1065. private SmartImportTaskInfo getLastEndTask(Context ctx, String userId, TaskTypeEnum taskType)
  1066. throws ShrWebBizException {
  1067. SmartImportTaskInfo taskInfo = null;
  1068. EntityViewInfo view = new EntityViewInfo();
  1069. FilterInfo filter = new FilterInfo();
  1070. filter.getFilterItems().add(new FilterItemInfo("creator", userId, CompareType.EQUALS));
  1071. filter.getFilterItems().add(new FilterItemInfo("taskType", taskType.getValue(), CompareType.EQUALS));
  1072. filter.getFilterItems().add(new FilterItemInfo("taskState", 7, CompareType.EQUALS));
  1073. filter.getFilterItems().add(new FilterItemInfo("taskState", 6, CompareType.EQUALS));
  1074. filter.getFilterItems().add(new FilterItemInfo("taskState", 8, CompareType.EQUALS));
  1075. filter.setMaskString("#0 and #1 and (#2 or #3 or #4)");
  1076. view.setFilter(filter);
  1077. SorterItemCollection sorterColl = new SorterItemCollection();
  1078. SorterItemInfo sorterItemInfo = new SorterItemInfo("taskStartDate");
  1079. sorterItemInfo.setSortType(SortType.DESCEND);
  1080. sorterColl.add(sorterItemInfo);
  1081. view.setSorter(sorterColl);
  1082. SelectorItemCollection selector = new SelectorItemCollection();
  1083. selector.add("*");
  1084. selector.add("recDemand.*");
  1085. selector.add("interRecommendation.*");
  1086. selector.add("resumeSource.*");
  1087. selector.add("recDemand.recuritPosition.*");
  1088. selector.add("recDemand.hrJob.*");
  1089. selector.add("resumeClip.*");
  1090. view.setSelector(selector);
  1091. try {
  1092. SmartImportTaskCollection taskColl = SmartImportTaskFactory.getLocalInstance(ctx)
  1093. .getSmartImportTaskCollection(view);
  1094. if (!RecDBUtils.isEmpty(taskColl)) {
  1095. taskInfo = taskColl.get(0);
  1096. }
  1097. return taskInfo;
  1098. } catch (BOSException var12) {
  1099. logger.error(var12.getMessage(), var12);
  1100. throw new ShrWebBizException("获取解析任务失败");
  1101. }
  1102. }
  1103. private SmartImportTaskDetailCollection getTaskDetailCollection(Context ctx, String taskId)
  1104. throws ShrWebBizException {
  1105. EntityViewInfo evi = new EntityViewInfo();
  1106. FilterInfo filter01 = new FilterInfo();
  1107. filter01.getFilterItems().add(new FilterItemInfo("task", taskId, CompareType.EQUALS));
  1108. evi.setFilter(filter01);
  1109. SelectorItemCollection selectorColl01 = evi.getSelector();
  1110. selectorColl01.add(new SelectorItemInfo("id"));
  1111. selectorColl01.add(new SelectorItemInfo("resumeFileName"));
  1112. selectorColl01.add(new SelectorItemInfo("resumeFileType"));
  1113. selectorColl01.add(new SelectorItemInfo("taskState"));
  1114. selectorColl01.add(new SelectorItemInfo("info"));
  1115. selectorColl01.add(new SelectorItemInfo("task"));
  1116. selectorColl01.add(new SelectorItemInfo("isDelete"));
  1117. SmartImportTaskDetailCollection detailColl = null;
  1118. try {
  1119. detailColl = SmartImportTaskDetailFactory.getLocalInstance(ctx).getSmartImportTaskDetailCollection(evi);
  1120. return detailColl;
  1121. } catch (BOSException var8) {
  1122. logger.error(var8.getMessage(), var8);
  1123. throw new ShrWebBizException("获取任务详情失败");
  1124. }
  1125. }
  1126. public void affirmSmartImportTaskResult(String smartImportTaskId) throws ShrWebBizException {
  1127. try {
  1128. SmartImportTaskFactory.getRemoteInstance().affirmTask(new ObjectUuidPK(smartImportTaskId));
  1129. } catch (BOSException var3) {
  1130. logger.error(var3.getMessage(), var3);
  1131. throw new ShrWebBizException("确认失败,请重试!");
  1132. }
  1133. }
  1134. public void deleteResume(String taskDetailIds) throws ShrWebBizException {
  1135. if (StringUtils.isEmpty(taskDetailIds)) {
  1136. throw new ShrWebBizException("请选择要删除的简历!");
  1137. } else {
  1138. String[] detailAry = taskDetailIds.split(",");
  1139. try {
  1140. SmartImportTaskDetailFactory.getRemoteInstance().deleteResumes(detailAry);
  1141. } catch (BOSException var4) {
  1142. logger.error(var4.getMessage(), var4);
  1143. throw new ShrWebBizException("服务器繁忙,请稍后重试!");
  1144. }
  1145. }
  1146. }
  1147. public void updateResume(Map<String, MultipartFile> fileMap, String resumeId, TaskTypeEnum taskType)
  1148. throws ShrWebBizException {
  1149. if (StringUtils.isEmpty(resumeId)) {
  1150. throw new ShrWebBizException("简历更新失败,resumeId为空!");
  1151. } else {
  1152. Context ctx = SHRContext.getInstance().getContext();
  1153. Iterator var5 = fileMap.entrySet().iterator();
  1154. while (true) {
  1155. if (var5.hasNext()) {
  1156. Map.Entry<String, MultipartFile> entity = (Map.Entry) var5.next();
  1157. MultipartFile mf = (MultipartFile) entity.getValue();
  1158. FileSafeUtil.checkFileCompliance(ctx, mf, FILETYPELIST, "DOC,DOCX,TXT,RTF,PDF,MSG,WPS,JPG,PNG,GIF");
  1159. String resumeFileName = mf.getOriginalFilename();
  1160. byte[] resumeFileData = null;
  1161. try {
  1162. resumeFileData = mf.getBytes();
  1163. } catch (IOException var12) {
  1164. logger.error(var12.getMessage(), var12);
  1165. throw new ShrWebBizException("附件上传失败,获取附件内容异常!");
  1166. }
  1167. if (StringUtils.isBlank(resumeFileName)) {
  1168. throw new ShrWebBizException("简历附件名不能为空:" + resumeFileName);
  1169. }
  1170. if (resumeFileData != null && resumeFileData.length >= this.resumeFileMinSize) {
  1171. if (resumeFileData.length > this.resumeFileMaxSize) {
  1172. throw new ShrWebBizException("简历附件大小不能超过:" + this.resumeFileMaxSize / 1024 / 1024 + "M!");
  1173. }
  1174. try {
  1175. boolean result = SmartResumeUpdateService.getInstance().smartResumeUpdate(ctx, mf, resumeId,
  1176. taskType);
  1177. if (!result) {
  1178. throw new ShrWebBizException("简历更新失败,请联系系统管理员!");
  1179. }
  1180. continue;
  1181. } catch (BOSException var11) {
  1182. logger.error(var11.getMessage(), var11);
  1183. throw new ShrWebBizException(var11.getMessage());
  1184. }
  1185. }
  1186. throw new ShrWebBizException("简历附件不能为空!");
  1187. }
  1188. return;
  1189. }
  1190. }
  1191. }
  1192. public void recoverSmartImportTask(Context ctx) throws BOSException {
  1193. if (logger.isDebugEnabled()) {
  1194. logger.debug("**********启动智能导入恢复任务recoverSmartImportTask**********");
  1195. }
  1196. Calendar c = Calendar.getInstance();
  1197. c.add(12, -35);
  1198. Date timeout = c.getTime();
  1199. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  1200. String timeoutStr = sdf.format(timeout);
  1201. SmartImportTaskCollection taskColl = null;
  1202. try {
  1203. taskColl = SmartImportTaskFactory.getLocalInstance(ctx).getSmartImportTaskCollection(
  1204. "where taskState = 9 or ((taskState = 4 or taskState = 2) and taskStartDate <= {ts'" + timeoutStr
  1205. + "'})");
  1206. } catch (BOSException var11) {
  1207. logger.error("*************************************获取超时及异常任务失败!*************************************");
  1208. logger.error(var11.getMessage(), var11);
  1209. }
  1210. if (!RecBaseUtils.isEmpty(taskColl)) {
  1211. Iterator<SmartImportTaskInfo> iter = taskColl.iterator();
  1212. SmartImportTaskInfo taskInfo = null;
  1213. while (iter.hasNext()) {
  1214. taskInfo = (SmartImportTaskInfo) iter.next();
  1215. try {
  1216. SmartImportTaskEntity TaskEntity = null;
  1217. if (TaskTypeEnum.SMARTIMPORT_RESUME.equals(taskInfo.getTaskType())) {
  1218. TaskEntity = new SmartImportTaskEntity(taskInfo, new ResumeSmartImportImpl(ctx,
  1219. taskInfo.getRecDemand().getId().toString(),
  1220. taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
  1221. taskInfo.getInterRecommendation() == null ? ""
  1222. : taskInfo.getInterRecommendation().getId().toString(),
  1223. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1224. } else if (TaskTypeEnum.SMARTIMPORT_RECOMMENDRESUME.equals(taskInfo.getTaskType())) {
  1225. TaskEntity = new SmartImportTaskEntity(taskInfo,
  1226. new RecommendResumeSmartImportImpl(taskInfo.getRecDemand().getId().toString(),
  1227. taskInfo.getInterRecommendation() == null ? ""
  1228. : taskInfo.getInterRecommendation().getId().toString(),
  1229. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1230. } else {
  1231. TaskEntity = new SmartImportTaskEntity(taskInfo, new ArchiveSmartImportImpl(ctx,
  1232. taskInfo.getResumeClip().getId().toString(),
  1233. taskInfo.getResumeSource() == null ? "" : taskInfo.getResumeSource().getId().toString(),
  1234. taskInfo.getInterRecommendation() == null ? ""
  1235. : taskInfo.getInterRecommendation().getId().toString(),
  1236. taskInfo.getSourceType() == null ? "" : taskInfo.getSourceType().toString()));
  1237. }
  1238. if (TaskEntity != null) {
  1239. this.submitTask(TaskEntity);
  1240. }
  1241. } catch (ShrWebBizException var10) {
  1242. logger.error("*******************恢复" + taskInfo.getId() + "任务失败!*******************");
  1243. logger.error(var10.getMessage(), var10);
  1244. }
  1245. }
  1246. } else if (logger.isDebugEnabled()) {
  1247. logger.debug("*************************************不存在超时及异常任务!*************************************");
  1248. }
  1249. }
  1250. private class TimeoutTaskCheckThread implements Runnable {
  1251. private TimeoutTaskCheckThread() {
  1252. }
  1253. public void run() {
  1254. if (SmartImportServiceEx.logger.isDebugEnabled()) {
  1255. SmartImportServiceEx.logger.debug("**************超时任务监控线程启动**************");
  1256. }
  1257. while (!Thread.currentThread().isInterrupted()) {
  1258. try {
  1259. FutureTimeTask future = (FutureTimeTask) SmartImportServiceEx.this.futureTaskQueue.take();
  1260. if (!future.timeoutCancel()) {
  1261. SmartImportServiceEx.this.futureTaskQueue.put(future);
  1262. }
  1263. Thread.sleep(100L);
  1264. } catch (InterruptedException var2) {
  1265. SmartImportServiceEx.logger.error("************************超时任务队列获取数据被异常中断***********************");
  1266. SmartImportServiceEx.logger.error(var2.getMessage(), var2);
  1267. } catch (Exception var3) {
  1268. SmartImportServiceEx.logger.error("************************超时任务队列获取数据异常***********************");
  1269. SmartImportServiceEx.logger.error(var3.getMessage(), var3);
  1270. }
  1271. }
  1272. if (SmartImportServiceEx.logger.isDebugEnabled()) {
  1273. SmartImportServiceEx.logger.debug("**************超时任务监控线程中断**************");
  1274. }
  1275. }
  1276. }
  1277. private class FutureTimeTask {
  1278. private Future future;
  1279. private SmartImportTaskEntity taskEntity;
  1280. public FutureTimeTask(SmartImportTaskEntity taskEntity, Future future) {
  1281. this.taskEntity = taskEntity;
  1282. this.future = future;
  1283. }
  1284. public boolean timeoutCancel() {
  1285. SmartImportTaskInfo taskInfo = this.taskEntity.getTaskInfo();
  1286. if (taskInfo.getTaskState().equals(TaskStateEnum.RUNNING)) {
  1287. if (!this.future.isDone()) {
  1288. long now = System.currentTimeMillis();
  1289. if (now - taskInfo.getTaskStartDate().getTime() <= SmartImportServiceEx.this.taskTimeoutMillis) {
  1290. return false;
  1291. }
  1292. this.future.cancel(true);
  1293. }
  1294. } else if (taskInfo.getTaskState().equals(TaskStateEnum.SUBMITED)) {
  1295. return false;
  1296. }
  1297. return true;
  1298. }
  1299. }
  1300. private static class SmartImportServiceHolder {
  1301. private static final SmartImportServiceEx service = new SmartImportServiceEx();
  1302. private SmartImportServiceHolder() {
  1303. }
  1304. }
  1305. }