PostServiceImpl.java 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. package com.hz.employmentsite.services.impl.companyService;
  2. import com.github.pagehelper.PageHelper;
  3. import com.github.pagehelper.PageInfo;
  4. import com.hz.employmentsite.filter.exception.BaseException;
  5. import com.hz.employmentsite.mapper.*;
  6. import com.hz.employmentsite.mapper.cquery.LabelCQuery;
  7. import com.hz.employmentsite.mapper.cquery.PostCQuery;
  8. import com.hz.employmentsite.model.*;
  9. import com.hz.employmentsite.services.service.companyService.PostService;
  10. import com.hz.employmentsite.services.service.system.DictionaryService;
  11. import com.hz.employmentsite.util.RegexUtils;
  12. import com.hz.employmentsite.util.StringUtils;
  13. import com.hz.employmentsite.util.ip.IpUtils;
  14. import com.hz.employmentsite.vo.companyService.PostVo;
  15. import com.hz.employmentsite.vo.companyService.RecommendPostVo;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.stereotype.Service;
  18. import javax.servlet.http.HttpServletRequest;
  19. import java.util.*;
  20. import java.util.stream.Collectors;
  21. @Service("PostService")
  22. public class PostServiceImpl implements PostService {
  23. @Autowired
  24. private PostCQuery postCQuery;
  25. @Autowired
  26. private StringUtils stringUtils;
  27. @Autowired
  28. private RegexUtils regexUtils;
  29. @Autowired
  30. private PcPostMapper pcPostMapper;
  31. @Autowired
  32. private PcRecommendMapper pcRecommendMapper;
  33. @Autowired
  34. private PcRecommendMgtMapper pcRecommendMgtMapper;
  35. @Autowired
  36. private PcProfessionMapper pcProfessionMapper;
  37. @Autowired
  38. private PcCompanyMapper companyMapper;
  39. @Autowired
  40. private PcSiteUserMapper pcSiteUserMapper;
  41. @Autowired
  42. private DictionaryService dictionaryService;
  43. @Autowired
  44. private PcLabelPostMapper pcLabelPostMapper;
  45. @Autowired
  46. private LabelCQuery labelCQuery;
  47. @Autowired
  48. private PcWorkcategoryMapper pcWorkcategoryMapper;
  49. @Autowired
  50. private SysLogMapper sysLogMapper;
  51. @Override
  52. public PageInfo<PostVo> getList(Integer page, Integer rows, List<String> postIDList,
  53. String professionName, Integer minCount, Integer maxCount,
  54. String companyName, String recordStatus, String companyID,
  55. String loginUserID, String siteID, Date startDate,
  56. Date endDate, String createUserName) {
  57. List<String> curLoginUserSiteCompanyIDs = new ArrayList<>();
  58. if (!stringUtils.IsNullOrEmpty(loginUserID)) {
  59. PcSiteUserExample siteUserExp = new PcSiteUserExample();
  60. siteUserExp.or().andUserIDEqualTo(loginUserID);
  61. var curLoginUserSiteID = pcSiteUserMapper.selectByExample(siteUserExp).get(0).getSiteID();
  62. PcCompanyExample companyExp = new PcCompanyExample();
  63. companyExp.or().andSiteIDEqualTo(curLoginUserSiteID);
  64. var curLoginUserSiteCompanyList = companyMapper.selectByExample(companyExp).stream().toList();
  65. for (PcCompany curLoginUserSiteCompany : curLoginUserSiteCompanyList) {
  66. curLoginUserSiteCompanyIDs.add(curLoginUserSiteCompany.getCompanyID());
  67. }
  68. }
  69. PageHelper.startPage(page, rows);
  70. List<PostVo> list = postCQuery.selectPostList(stringUtils.ListToInSql(postIDList), professionName, minCount, maxCount,
  71. companyName, recordStatus, companyID, stringUtils.ListToInSql(curLoginUserSiteCompanyIDs),
  72. siteID, startDate, endDate,false, createUserName);
  73. if(list != null && list.size()>0){
  74. for(PostVo curPost : list){
  75. curPost.listLabel = labelCQuery.getPostLabelList(curPost.getPostID());
  76. var curPcPost = pcPostMapper.selectByPrimaryKey(curPost.getPostID());
  77. if (!stringUtils.IsNullOrEmpty(curPost.professionID)&&stringUtils.IsNullOrEmpty(curPost.postName)){
  78. PcProfessionExample professionExp = new PcProfessionExample();
  79. professionExp.or().andProfessionIDEqualTo(curPost.professionID);
  80. var curProfession = pcProfessionMapper.selectByExample(professionExp).stream().findFirst().orElse(null);
  81. if( curProfession!=null){
  82. curPcPost.setPostName(curProfession.getProfessionName());
  83. pcPostMapper.updateByPrimaryKey(curPcPost);
  84. }
  85. }
  86. if (!stringUtils.IsNullOrEmpty(curPost.workCode)&&stringUtils.IsNullOrEmpty(curPost.workName)){
  87. PcWorkcategoryExample workCategoryExp = new PcWorkcategoryExample();
  88. workCategoryExp.or().andWorkCategoryIDEqualTo(curPost.workCode);
  89. var curWorkCategory = pcWorkcategoryMapper.selectByExample(workCategoryExp).stream().findFirst().orElse(null);
  90. if( curWorkCategory!=null){
  91. curPcPost.setWorkName(curWorkCategory.getWorkCategoryName());
  92. pcPostMapper.updateByPrimaryKey(curPcPost);
  93. }
  94. }
  95. if (curPost.endTime != null && curPost.endTime.before(new Date()) && curPost.recordStatus.equals(1)) {
  96. curPcPost.setRecordStatus(0);
  97. pcPostMapper.updateByPrimaryKey(curPcPost);
  98. }
  99. }
  100. }
  101. PageInfo<PostVo> result = new PageInfo(list);
  102. return result;
  103. }
  104. @Override
  105. public Integer getRecruitCount(String professionName, Integer minCount, Integer maxCount,
  106. String companyName, String recordStatus, String companyID,
  107. String siteID, Date startDate,Date endDate, String createUserName) {
  108. return postCQuery.selectPostRecruitCount(professionName, minCount, maxCount,
  109. companyName, recordStatus, companyID, siteID, startDate, endDate,false, createUserName);
  110. }
  111. @Override
  112. public PageInfo<RecommendPostVo> getCommendPostList(Integer page, Integer rows, String jobUserID) {
  113. PageHelper.startPage(page, rows);
  114. List<RecommendPostVo> list = postCQuery.selectRecommendPostList(jobUserID);
  115. PageInfo<RecommendPostVo> result = new PageInfo(list);
  116. return result;
  117. }
  118. @Override
  119. public Integer saveCommendPost(RecommendPostVo data, String userId) {
  120. int result = 0;
  121. PcRecommend dbData = null;
  122. if (data.recommendID != null) {
  123. PcRecommendExample exp = new PcRecommendExample();
  124. PcRecommendExample.Criteria cro = exp.createCriteria();
  125. cro.andPostIDEqualTo(data.recommendID);
  126. dbData = pcRecommendMapper.selectByExample(exp).stream().findFirst().orElse(null);
  127. }
  128. Boolean isExist = dbData != null;
  129. if (!isExist) {
  130. dbData = new PcRecommend();
  131. dbData.setRecommendID(UUID.randomUUID().toString());
  132. dbData.setJobuserID(data.jobUserID);
  133. dbData.setPostID(data.postID);
  134. dbData.setIsRead(data.isRead == null ? false : true);
  135. dbData.setIsSendnotes(data.isSendNotes == null ? false : true);
  136. dbData.setCreateTime(new Date());
  137. dbData.setCreateUserID(userId);
  138. result = pcRecommendMapper.insert(dbData);
  139. } else {
  140. dbData.setJobuserID(data.jobUserID);
  141. dbData.setPostID(data.postID);
  142. dbData.setIsRead(data.isRead == null ? false : true);
  143. dbData.setIsSendnotes(data.isSendNotes == null ? false : true);
  144. dbData.setModifyTime(new Date());
  145. dbData.setModifyUserID(userId);
  146. result = pcRecommendMapper.updateByPrimaryKeySelective(dbData);
  147. }
  148. return result;
  149. }
  150. @Override
  151. public int updatePostStatus(String postID, Integer status) {
  152. PcPost post = pcPostMapper.selectByPrimaryKey(postID);
  153. if(status.equals(1)&&post.getEndTime().before(new Date())){
  154. throw new BaseException("","该岗位招聘日期已结束,不能启用!");
  155. }
  156. post.setRecordStatus(status);
  157. return pcPostMapper.updateByPrimaryKey(post);
  158. }
  159. @Override
  160. public int save(PostVo data, String userId) {
  161. int result = 0;
  162. PcPost dbData = null;
  163. Boolean isExist = data.getPostID() != null;
  164. PcPostExample exp = new PcPostExample();
  165. PcPostExample.Criteria cro = exp.createCriteria();
  166. if (isExist) {
  167. cro.andPostIDEqualTo(data.getPostID());
  168. dbData = pcPostMapper.selectByExample(exp).stream().findFirst().orElse(null);
  169. }
  170. if (dbData == null && !stringUtils.IsNullOrEmpty(data.getOracleTableID())) {
  171. exp = new PcPostExample();
  172. cro = exp.createCriteria();
  173. cro.andOracleTableIDEqualTo(data.getOracleTableID());
  174. List<PcPost> post = pcPostMapper.selectByExample(exp);
  175. if (!post.isEmpty()) {
  176. // 不重复录入oracle同步数据
  177. return 0;
  178. }
  179. }
  180. //判断岗位id是否为空
  181. if (stringUtils.IsNullOrEmpty(data.getProfessionID())) {
  182. PcProfessionExample proEmp = new PcProfessionExample();
  183. PcProfessionExample.Criteria proCia = proEmp.or();
  184. proCia.andParentProfessionIDNotEqualTo("");
  185. proCia.andProfessionNameEqualTo("其他");
  186. //获取二级其他信息
  187. PcProfession proOther = pcProfessionMapper.selectByExample(proEmp).stream().findFirst().orElse(null);
  188. if (proOther != null) {
  189. proEmp = new PcProfessionExample();
  190. proEmp.or().andParentProfessionIDEqualTo(proOther.getProfessionID()).andProfessionNameIsNotNull();
  191. // proCia.andProfessionNameEqualTo(data.getProfessionName());
  192. //查询其他岗位
  193. List<PcProfession> proOtherSonList = pcProfessionMapper.selectByExample(proEmp);
  194. PcProfession proOtherSon = proOtherSonList.stream()
  195. .filter(x -> x.getProfessionName().equals(data.getProfessionName())).findFirst().orElse(null);
  196. if (proOtherSon != null) {
  197. data.setProfessionID(proOtherSon.getProfessionID());
  198. } else {
  199. data.setProfessionID(UUID.randomUUID().toString());
  200. PcProfession proModel = new PcProfession();
  201. proModel.setProfessionID(data.getProfessionID());
  202. proModel.setParentProfessionID(proOther.getProfessionID());
  203. proModel.setProfessionName(data.getProfessionName());
  204. proModel.setStatus(Integer.parseInt("1"));
  205. proModel.setOrderNo(proOtherSonList.size() + 1);
  206. pcProfessionMapper.insert(proModel);
  207. }
  208. }
  209. }
  210. if (dbData == null) {
  211. dbData = new PcPost();
  212. dbData.setPostID(UUID.randomUUID().toString());
  213. dbData.setProfessionID(data.getProfessionID());
  214. dbData.setWorkCode(data.getWorkCode());
  215. dbData.setWorkName(data.getWorkName());
  216. dbData.setValidTime(data.getValidTime());
  217. dbData.setRecruitCount(data.getRecruitCount());
  218. dbData.setCompanyID(data.getCompanyID());
  219. dbData.setPostName(data.getPostName());
  220. dbData.setRecordStatus(data.getRecordStatus());
  221. dbData.setWorkNature(data.getWorkNature());
  222. dbData.setValidDay(data.getValidDay());
  223. dbData.setWorkYear(data.getWorkYear());
  224. dbData.setWorkNature(data.getWorkNature());
  225. dbData.setCultureRank(data.getCultureRank());
  226. dbData.setPostDesc(data.getPostDesc());
  227. dbData.setMaxSalary(data.getMaxSalary());
  228. dbData.setMinSalary(data.getMinSalary());
  229. dbData.setWelfare(data.getWelfare());
  230. dbData.setUserName(data.getUserName());
  231. dbData.setUserMobile(data.getUserMobile());
  232. dbData.setPostEmail(data.getPostEmail());
  233. dbData.setWorkTime(data.getWorkTime());
  234. dbData.setIsTrail(data.getIsTrail());
  235. dbData.setTrailMonths(data.getTrailMonths());
  236. dbData.setTrailMaxSalary(data.getTrailMaxSalary());
  237. dbData.setTrailMinSalary(data.getTrailMinSalary());
  238. dbData.setCreateTime(new Date());
  239. dbData.setCreateUserID(userId);
  240. dbData.setJobPlace(data.getJobPlace());
  241. dbData.setStartTime(data.getStartTime());
  242. dbData.setEndTime(data.getEndTime());
  243. dbData.setContactName(data.getContactName());
  244. dbData.setContactMobile(data.getContactMobile());
  245. dbData.setContactEmail(data.getContactEmail());
  246. dbData.setWorkNatureID(data.getWorkNatureID());
  247. dbData.setOracleTableID(data.getOracleTableID());
  248. // dbData.setTagID(data.getTagID());
  249. result = pcPostMapper.insert(dbData);
  250. } else {
  251. dbData.setProfessionID(data.getProfessionID());
  252. dbData.setWorkCode(data.getWorkCode());
  253. dbData.setValidTime(data.getValidTime());
  254. dbData.setWorkName(data.getWorkName());
  255. dbData.setRecruitCount(data.getRecruitCount());
  256. dbData.setCompanyID(data.getCompanyID());
  257. dbData.setPostName(data.getPostName());
  258. dbData.setRecordStatus(data.getRecordStatus());
  259. dbData.setWorkNature(data.getWorkNature());
  260. dbData.setValidDay(data.getValidDay());
  261. dbData.setWorkYear(data.getWorkYear());
  262. dbData.setWorkNature(data.getWorkNature());
  263. dbData.setCultureRank(data.getCultureRank());
  264. dbData.setPostDesc(data.getPostDesc());
  265. dbData.setMaxSalary(data.getMaxSalary());
  266. dbData.setMinSalary(data.getMinSalary());
  267. dbData.setWelfare(data.getWelfare());
  268. dbData.setUserName(data.getUserName());
  269. dbData.setUserMobile(data.getUserMobile());
  270. dbData.setPostEmail(data.getPostEmail());
  271. dbData.setWorkTime(data.getWorkTime());
  272. dbData.setIsTrail(data.getIsTrail());
  273. dbData.setTrailMonths(data.getTrailMonths());
  274. dbData.setTrailMaxSalary(data.getTrailMaxSalary());
  275. dbData.setTrailMinSalary(data.getTrailMinSalary());
  276. dbData.setModifyTime(new Date());
  277. dbData.setModifyUserID(userId);
  278. dbData.setJobPlace(data.getJobPlace());
  279. dbData.setStartTime(data.getStartTime());
  280. dbData.setEndTime(data.getEndTime());
  281. dbData.setContactName(data.getContactName());
  282. dbData.setContactMobile(data.getContactMobile());
  283. dbData.setContactEmail(data.getContactEmail());
  284. dbData.setWorkNatureID(data.getWorkNatureID());
  285. dbData.setOracleTableID(data.getOracleTableID());
  286. // dbData.setTagID(data.getTagID());
  287. result = pcPostMapper.updateByPrimaryKeyWithBLOBs(dbData);
  288. }
  289. PcLabelPostExample labelEmp = new PcLabelPostExample();
  290. labelEmp.or().andPostIDEqualTo(data.getPostID());
  291. pcLabelPostMapper.deleteByExample(labelEmp);
  292. if (data.listLabel != null && data.listLabel.size() > 0) {
  293. data.listLabel.forEach(x -> {
  294. PcLabelPost labelModel = new PcLabelPost();
  295. labelModel.setPostID(data.getPostID());
  296. labelModel.setLabelID(x.getLabelID());
  297. pcLabelPostMapper.insert(labelModel);
  298. });
  299. }
  300. return result;
  301. }
  302. @Override
  303. public int delete(HttpServletRequest request, List<String> idList, String loginUserID) {
  304. int result = 0;
  305. PcRecommendMgtExample recommendMgtExp = new PcRecommendMgtExample();
  306. recommendMgtExp.or().andPostIDIn(idList);
  307. List<PcRecommendMgt> resultList = pcRecommendMgtMapper.selectByExample(recommendMgtExp).stream().toList();
  308. if( resultList.size() > 0 ) {
  309. throw new BaseException("10004","已存在该岗位的推荐数据,删除失败!");
  310. }
  311. PcPostExample postExp = new PcPostExample();
  312. postExp.or().andPostIDIn(idList);
  313. // 查询岗位的相关企业
  314. List<PostVo> postVos = postCQuery.selectPostList(stringUtils.ListToInSql(idList), null, null, null, null, null, null, null, null, null, null, false, null);
  315. // 记录删除数据
  316. String delInfo = "删除岗位:";
  317. for (PostVo post : postVos) {
  318. delInfo += post.getCompanyName() + "(" + post.getProfessionName() + "),";
  319. }
  320. result = pcPostMapper.deleteByExample(postExp);
  321. if (result > 0) {
  322. PcLabelPostExample labelEmp = new PcLabelPostExample();
  323. labelEmp.or().andPostIDIn(idList);
  324. pcLabelPostMapper.deleteByExample(labelEmp);
  325. // 记录删除日志
  326. SysLog sysLog = new SysLog();
  327. sysLog.setLogID(UUID.randomUUID().toString());
  328. sysLog.setPageName("岗位信息管理");
  329. sysLog.setPageUrl("/companyService/post/delete");
  330. sysLog.setActionName("删除岗位");
  331. sysLog.setUserID(loginUserID);
  332. sysLog.setLogTime(new Date());
  333. sysLog.setIPAddress(IpUtils.getIpAddr(request));
  334. sysLog.setOperationData(delInfo.substring(0, delInfo.length() - 1)); // 注意移除最后一个,
  335. sysLogMapper.insert(sysLog);
  336. }
  337. return result;
  338. }
  339. @Override
  340. public int deletePostAndRecommendMgt(HttpServletRequest request, String id, String loginUserID) {
  341. try {
  342. PcRecommendMgtExample exp = new PcRecommendMgtExample();
  343. PcRecommendMgtExample.Criteria cro = exp.or();
  344. cro.andPostIDEqualTo(id);
  345. pcRecommendMgtMapper.deleteByExample(exp);
  346. PcLabelPostExample labelEmp = new PcLabelPostExample();
  347. labelEmp.or().andPostIDEqualTo(id);
  348. pcLabelPostMapper.deleteByExample(labelEmp);
  349. // 查询岗位的相关企业
  350. List<PostVo> postVos = postCQuery.selectPostList(stringUtils.ListToInSql(Arrays.asList(id)), null, null, null, null, null, null, null, null, null, null, false, null);
  351. // 记录删除数据
  352. String delInfo = "删除岗位:";
  353. for (PostVo post : postVos) {
  354. delInfo += post.getCompanyName() + "(" + post.getProfessionName() + ")";
  355. }
  356. int result = pcPostMapper.deleteByPrimaryKey(id);
  357. if (result > 0) {
  358. // 记录删除日志
  359. SysLog sysLog = new SysLog();
  360. sysLog.setLogID(UUID.randomUUID().toString());
  361. sysLog.setPageName("岗位信息管理");
  362. sysLog.setPageUrl("/companyService/post/delete");
  363. sysLog.setActionName("删除岗位");
  364. sysLog.setUserID(loginUserID);
  365. sysLog.setLogTime(new Date());
  366. sysLog.setIPAddress(IpUtils.getIpAddr(request));
  367. sysLog.setOperationData(delInfo);
  368. sysLogMapper.insert(sysLog);
  369. }
  370. return result;
  371. } catch (Exception e) {
  372. e.printStackTrace();
  373. return 0;
  374. }
  375. }
  376. @Override
  377. public PostVo getDataById(String id,boolean isAllPost) {
  378. if (stringUtils.IsNullOrEmpty(id)) {
  379. return null;
  380. }
  381. PostVo data = postCQuery.selectPostList(stringUtils.ListToInSql(Arrays.asList(id)), null, null, null, null, null, null, null, null, null, null,isAllPost,null).stream().findFirst().orElse(null);
  382. if (data != null) {
  383. data.listLabel = labelCQuery.getPostLabelList(id);
  384. }
  385. return data;
  386. }
  387. @Override
  388. public List<PostVo> getDataListByCompanyID(String companyId) {
  389. List<PostVo> resultList = new ArrayList<>();
  390. PcPostExample postExp = new PcPostExample();
  391. postExp.or().andCompanyIDEqualTo(companyId);
  392. var postList = pcPostMapper.selectByExample(postExp);
  393. for (PcPost curPost : postList) {
  394. PostVo item = new PostVo();
  395. item.setPostID(curPost.getPostID());
  396. item.setProfessionID(curPost.getProfessionID());
  397. PcProfessionExample professionExp = new PcProfessionExample();
  398. professionExp.or().andProfessionIDEqualTo(curPost.getProfessionID());
  399. var curProfession = pcProfessionMapper.selectByExample(professionExp).get(0);
  400. item.setProfessionName(curProfession.getProfessionName());
  401. item.setCompanyID(curPost.getCompanyID());
  402. item.setRecruitCount(curPost.getRecruitCount());
  403. item.setStartTime(curPost.getStartTime());
  404. item.setEndTime(curPost.getEndTime());
  405. resultList.add(item);
  406. }
  407. return resultList;
  408. }
  409. public static boolean isPositiveInteger(String str) {
  410. try {
  411. // 尝试将字符串转换为整数
  412. int num = Integer.parseInt(str);
  413. // 如果转换后的整数小于等于0,则为false
  414. return num > 0;
  415. } catch (NumberFormatException e) {
  416. // 字符串无法转换为整数,则为false
  417. return false;
  418. }
  419. }
  420. @Override
  421. public List<PostVo> importPost(List<PostVo> dataList, String userID) {
  422. if (dataList.size() <= 0)
  423. throw new BaseException("", "请添加导入数据!");
  424. //所属企业
  425. PcCompanyExample companyExp = new PcCompanyExample();
  426. companyExp.or().andRecordStatusEqualTo(1);
  427. List<PcCompany> companyList = companyMapper.selectByExample(companyExp);
  428. //岗位信息
  429. List<SysDictionaryItem> thirdLevelProfessionList = new ArrayList<>();
  430. PcProfessionExample professionExp = new PcProfessionExample();
  431. professionExp.or().andParentProfessionIDEqualTo("").andStatusEqualTo(1);
  432. var firstLevelData = pcProfessionMapper.selectByExample(professionExp);
  433. for (PcProfession curProfession : firstLevelData) {
  434. professionExp = new PcProfessionExample();
  435. professionExp.or().andParentProfessionIDEqualTo(curProfession.getProfessionID()).andStatusEqualTo(1);
  436. var secondLevelData = pcProfessionMapper.selectByExample(professionExp);
  437. for (PcProfession curParentProfession : secondLevelData) {
  438. professionExp = new PcProfessionExample();
  439. professionExp.or().andParentProfessionIDEqualTo(curParentProfession.getProfessionID()).andStatusEqualTo(1).andProfessionNameIsNotNull();
  440. var thirdLevelData = pcProfessionMapper.selectByExample(professionExp);
  441. for (PcProfession curItem : thirdLevelData) {
  442. SysDictionaryItem item = new SysDictionaryItem();
  443. item.setCode(curItem.getProfessionID());
  444. item.setName(curItem.getProfessionName());
  445. thirdLevelProfessionList.add(item);
  446. }
  447. }
  448. }
  449. // 工种信息
  450. List<SysDictionaryItem> WorkCategoryList = new ArrayList<>();
  451. // 获取第一级工种
  452. PcWorkcategoryExample workCategoryExample = new PcWorkcategoryExample();
  453. workCategoryExample.or().andParentWorkCategoryIDEqualTo("").andStatusEqualTo(1);
  454. List<PcWorkcategory> firstLevelWorkCategoryList = pcWorkcategoryMapper.selectByExample(workCategoryExample);
  455. for (PcWorkcategory pcWorkcategory : firstLevelWorkCategoryList) {
  456. // 获取第二级工种
  457. workCategoryExample = new PcWorkcategoryExample();
  458. workCategoryExample.or().andParentWorkCategoryIDEqualTo(pcWorkcategory.getWorkCategoryID()).andStatusEqualTo(1);
  459. List<PcWorkcategory> secondLevelWorkCategoryList = pcWorkcategoryMapper.selectByExample(workCategoryExample);
  460. for (PcWorkcategory workCategory : secondLevelWorkCategoryList) {
  461. // 获取第三级工种
  462. workCategoryExample = new PcWorkcategoryExample();
  463. workCategoryExample.or().andParentWorkCategoryIDEqualTo(workCategory.getWorkCategoryID()).andStatusEqualTo(1);
  464. List<PcWorkcategory> thirdLevelWorkCategoryList = pcWorkcategoryMapper.selectByExample(workCategoryExample);
  465. for (PcWorkcategory pcWorkCategory1 : thirdLevelWorkCategoryList) {
  466. SysDictionaryItem item = new SysDictionaryItem();
  467. item.setCode(pcWorkCategory1.getWorkCategoryID());
  468. item.setName(pcWorkCategory1.getWorkCategoryName());
  469. WorkCategoryList.add(item);
  470. }
  471. }
  472. }
  473. //文化程度
  474. List<SysDictionaryItem> dicCultureDataList = dictionaryService.getDictionaryItemList("CultureLevel");
  475. // 工作年限
  476. List<SysDictionaryItem> dicWorkYearDataList = dictionaryService.getDictionaryItemList("WorkYearType");
  477. // 最终处理数据
  478. List<PostVo> resultList = new ArrayList<>(); // 岗位
  479. List<PcProfession> pcProfessionList = new ArrayList<>(); // 岗位字典
  480. // 获取二级的“其他”岗位
  481. PcProfessionExample proEmp = new PcProfessionExample();
  482. PcProfessionExample.Criteria proCia = proEmp.or();
  483. proCia.andParentProfessionIDNotEqualTo("");
  484. proCia.andProfessionNameEqualTo("其他");
  485. PcProfession proOther = pcProfessionMapper.selectByExample(proEmp).stream().findFirst().orElse(null);
  486. proEmp = new PcProfessionExample();
  487. proEmp.or().andParentProfessionIDEqualTo(proOther.getProfessionID()).andProfessionNameIsNotNull();
  488. //查询已存在的三级“其他”岗位
  489. List<PcProfession> proOtherSonList = pcProfessionMapper.selectByExample(proEmp);
  490. dataList.forEach(item -> {
  491. String errorInfo = "";
  492. item.setPostID(UUID.randomUUID().toString());
  493. item.setRecordStatus(1);
  494. if (stringUtils.IsNullOrEmpty(item.companyName))
  495. errorInfo += "请填写企业名称!";
  496. else {
  497. item.companyID = companyList.stream().filter(it -> it.getCompanyName().equals(item.getCompanyName().trim()))
  498. .findFirst().orElse(new PcCompany()).getCompanyID();
  499. if (item.companyID == null)
  500. errorInfo += "企业不存在!";
  501. }
  502. if (stringUtils.IsNullOrEmpty(item.professionName))
  503. errorInfo += "请填写岗位名称!";
  504. else {
  505. item.professionID = thirdLevelProfessionList.stream().filter(it -> it.getName() != null && it.getName().equals(item.getProfessionName().trim()))
  506. .findFirst().orElse(new SysDictionaryItem()).getCode();
  507. if (item.professionID == null || item.professionID == "") {
  508. // 如果岗位不存在,则在“其他”下添加一个
  509. if (proOther != null) {
  510. item.setProfessionID(UUID.randomUUID().toString());
  511. PcProfession proModel = new PcProfession();
  512. proModel.setProfessionID(item.getProfessionID());
  513. proModel.setParentProfessionID(proOther.getProfessionID());
  514. proModel.setProfessionName(item.getProfessionName());
  515. proModel.setStatus(Integer.parseInt("1"));
  516. proModel.setOrderNo(proOtherSonList.size() + 1);
  517. pcProfessionList.add(proModel);
  518. // 先将该岗位临时存储在第三级数据中,防止在最终添加之前,向pcProfessionList生成多个相同名称的岗位字典数据
  519. SysDictionaryItem dictionaryItem = new SysDictionaryItem();
  520. dictionaryItem.setCode(item.getProfessionID());
  521. dictionaryItem.setName(item.getProfessionName());
  522. thirdLevelProfessionList.add(dictionaryItem);
  523. }
  524. }
  525. }
  526. if (stringUtils.IsNullOrEmpty(item.getWorkCategoryName())) {
  527. errorInfo += "请填写工种名称";
  528. } else {
  529. item.workCode = WorkCategoryList.stream().filter(it -> it.getName() != null && it.getName().equals(item.getWorkCategoryName().trim()))
  530. .findFirst().orElse(new SysDictionaryItem()).getCode();
  531. if (item.workCode == null || item.workCode == "") {
  532. errorInfo += "工种不存在!";
  533. }else{
  534. item.workName = item.getWorkCategoryName();
  535. }
  536. }
  537. if (stringUtils.IsNullOrEmpty(String.valueOf(item.recruitCountStr)))
  538. errorInfo += "请填写招聘人数!";
  539. else{
  540. if(!isPositiveInteger(item.recruitCountStr)){
  541. errorInfo += "招聘人数必须为一个正整数!";
  542. }else{
  543. item.setRecruitCount(Integer.valueOf(item.recruitCountStr));
  544. }
  545. }
  546. if (stringUtils.IsNullOrEmpty(String.valueOf(item.startTime)) || item.startTime == null)
  547. errorInfo += "请填写开始日期!";
  548. if (stringUtils.IsNullOrEmpty(String.valueOf(item.startTime)) || item.startTime == null)
  549. errorInfo += "请填写结束日期!";
  550. if (stringUtils.IsNullOrEmpty(item.jobPlace))
  551. errorInfo += "请填写工作地点!";
  552. if (!stringUtils.IsNullOrEmpty(item.getWorkYearName())) {
  553. item.workYear = dicWorkYearDataList.stream().filter(it -> it.getName() != null && it.getName().equals(item.getWorkYearName().trim()))
  554. .findFirst().orElse(new SysDictionaryItem()).getValue();
  555. if (item.workYear == null)
  556. errorInfo += "工作年限不存在!";
  557. }
  558. if (item.isTrailName.trim().equals("是")) item.isTrail = true;
  559. else if (item.isTrailName.trim().equals("否")) item.isTrail = false;
  560. if (!stringUtils.IsNullOrEmpty(item.cultureLevelName)) {
  561. item.cultureRank = dicCultureDataList.stream().filter(it -> it.getName() != null && it.getName().equals(item.cultureLevelName.trim()))
  562. .findFirst().orElse(new SysDictionaryItem()).getValue();
  563. if (item.cultureRank == null || item.cultureRank == 0)
  564. errorInfo += "输入的学历要求不存在!";
  565. }
  566. if (!stringUtils.IsNullOrEmpty(item.getContactMobile())) {
  567. if (!regexUtils.theMobileIsValid( item.contactMobile,true)) {
  568. errorInfo += "输入的联系人电话格式不正确";
  569. }
  570. }
  571. if (!stringUtils.IsNullOrEmpty(item.getCompanyEmail())) {
  572. if (!regexUtils.theEmailIsValid(item.contactEmail)) {
  573. errorInfo += "输入的邮箱格式不正确";
  574. }
  575. }
  576. if (stringUtils.IsNullOrEmpty(errorInfo)) {
  577. resultList.add(item);
  578. } else {
  579. item.setErrorMessage(errorInfo);
  580. }
  581. });
  582. if (dataList.stream().filter(it -> !stringUtils.IsNullOrEmpty(it.errorMessage)).collect(Collectors.toList()).size() > 0)
  583. return dataList;
  584. resultList.forEach(item -> {
  585. save(item, userID);
  586. });
  587. // 添加岗位名称字典
  588. pcProfessionList.forEach(item -> {
  589. pcProfessionMapper.insert(item);
  590. });
  591. return null;
  592. }
  593. /**
  594. * 企业数据可视化地图页面获取岗位
  595. *
  596. * @param companyID 企业ID
  597. * @return 岗位信息
  598. */
  599. @Override
  600. public PageInfo<PostVo> selectCompanyMapPostList(int pageIndex, int pageSize, String companyID) {
  601. PageHelper.startPage(pageIndex, pageSize);
  602. List<PostVo> postVos = postCQuery.selectCompanyMapPostList(companyID);
  603. PageInfo<PostVo> result = new PageInfo(postVos);
  604. return result;
  605. }
  606. }