DemandServiceImpl.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. package com.goafanti.demand.service.impl;
  2. import java.math.BigDecimal;
  3. import java.text.ParseException;
  4. import java.util.ArrayList;
  5. import java.util.Calendar;
  6. import java.util.Date;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import java.util.UUID;
  11. import org.apache.commons.lang3.StringUtils;
  12. import org.springframework.beans.BeanUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.stereotype.Service;
  15. import com.goafanti.achievement.bo.AchievementDemandListBo;
  16. import com.goafanti.common.constant.AFTConstants;
  17. import com.goafanti.common.dao.AchievementDemandMapper;
  18. import com.goafanti.common.dao.AchievementKeywordMapper;
  19. import com.goafanti.common.dao.DemandKeywordMapper;
  20. import com.goafanti.common.dao.DemandMapper;
  21. import com.goafanti.common.dao.NoticeMapper;
  22. import com.goafanti.common.dao.UserMapper;
  23. import com.goafanti.common.dao.UserRoleMapper;
  24. import com.goafanti.common.enums.DeleteStatus;
  25. import com.goafanti.common.enums.DemandAuditStatus;
  26. import com.goafanti.common.enums.DemandInfoSourceStatus;
  27. import com.goafanti.common.enums.DemandReleaseStatus;
  28. import com.goafanti.common.enums.DemandStatus;
  29. import com.goafanti.common.enums.NoticeReadStatus;
  30. import com.goafanti.common.enums.NoticeStatus;
  31. import com.goafanti.common.enums.UserType;
  32. import com.goafanti.common.model.AchievementDemand;
  33. import com.goafanti.common.model.Demand;
  34. import com.goafanti.common.model.DemandKeyword;
  35. import com.goafanti.common.model.Notice;
  36. import com.goafanti.common.model.User;
  37. import com.goafanti.common.utils.DateUtils;
  38. import com.goafanti.core.mybatis.BaseMybatisDao;
  39. import com.goafanti.core.mybatis.page.Pagination;
  40. import com.goafanti.core.shiro.token.TokenManager;
  41. import com.goafanti.demand.bo.DemandImportBo;
  42. import com.goafanti.demand.bo.DemandListBo;
  43. import com.goafanti.demand.bo.DemandManageDetailBo;
  44. import com.goafanti.demand.bo.DemandManageListBo;
  45. import com.goafanti.demand.bo.DemandPartnerListBo;
  46. import com.goafanti.demand.service.DemandService;
  47. import com.goafanti.portal.bo.DemandPortalDetailBo;
  48. import com.goafanti.portal.bo.DemandPortalSimilarListBo;
  49. import com.goafanti.portal.bo.DemandSearchDetailBo;
  50. import com.goafanti.portal.bo.DemandSearchListBo;
  51. @Service
  52. public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements DemandService {
  53. @Autowired
  54. private DemandMapper demandMapper;
  55. @Autowired
  56. private UserMapper userMapper;
  57. @Autowired
  58. private UserRoleMapper userRoleMapper;
  59. @Autowired
  60. private NoticeMapper noticeMapper;
  61. @Autowired
  62. private DemandKeywordMapper demandKeywordMapper;
  63. @Autowired
  64. private AchievementDemandMapper achievementDemandMapper;
  65. @Autowired
  66. private AchievementKeywordMapper achievementKeywordMapper;
  67. @SuppressWarnings("unchecked")
  68. @Override
  69. public Pagination<DemandManageListBo> selectUserDemandManageList(Integer auditStatus, Integer province,
  70. Integer serialNumber, String name, String keyword, Integer infoSources, Integer demandType,
  71. String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
  72. Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
  73. Map<String, Object> params = disposeParams(auditStatus, province, serialNumber, name, keyword, infoSources,
  74. demandType, validityPeriodStartDate, validityPeriodEndDate, username, status, releaseStatus,
  75. releaseDateStartDate, releaseDateEndDate);
  76. if (pNo == null || pNo < 0) {
  77. pNo = 1;
  78. }
  79. if (pSize == null || pSize < 0 || pSize > 10) {
  80. pSize = 10;
  81. }
  82. if (TokenManager.hasRole(AFTConstants.SALESMANAGERADMIN) || TokenManager.hasRole(AFTConstants.SALESMANADMIN)) {
  83. params.put("principal", TokenManager.getAdminId());
  84. }
  85. if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
  86. params.put("mid", TokenManager.getAdminId());
  87. }
  88. if (TokenManager.hasRole(AFTConstants.TECHBROKER)) {
  89. params.put("techBroker", TokenManager.getAdminId());
  90. }
  91. return (Pagination<DemandManageListBo>) findPage("findManageUserDemandListByPage", "findManageUserDemandCount",
  92. params, pNo, pSize);
  93. }
  94. @SuppressWarnings("unchecked")
  95. @Override
  96. public Pagination<DemandManageListBo> selectOrgDemandManageList(Integer auditStatus, Integer province,
  97. Integer serialNumber, String name, String keyword, Integer infoSources, Integer demandType,
  98. String validityPeriodStartDate, String validityPeriodEndDate, String username, Integer status,
  99. Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
  100. Map<String, Object> params = disposeParams(auditStatus, province, serialNumber, name, keyword, infoSources,
  101. demandType, validityPeriodStartDate, validityPeriodEndDate, username, status, releaseStatus,
  102. releaseDateStartDate, releaseDateEndDate);
  103. if (pNo == null || pNo < 0) {
  104. pNo = 1;
  105. }
  106. if (pSize == null || pSize < 0 || pSize > 10) {
  107. pSize = 10;
  108. }
  109. if (TokenManager.hasRole(AFTConstants.SALESMANAGERADMIN) || TokenManager.hasRole(AFTConstants.SALESMANADMIN)) {
  110. params.put("principal", TokenManager.getAdminId());
  111. }
  112. if (TokenManager.hasRole(AFTConstants.MANAGERADMIN)) {
  113. params.put("mid", TokenManager.getAdminId());
  114. }
  115. if (TokenManager.hasRole(AFTConstants.TECHBROKER)) {
  116. params.put("techBroker", TokenManager.getAdminId());
  117. }
  118. return (Pagination<DemandManageListBo>) findPage("findManageOrgDemandListByPage", "findManageOrgDemandCount",
  119. params, pNo, pSize);
  120. }
  121. @Override
  122. public void saveUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
  123. Date validityPeriod = null;
  124. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  125. try {
  126. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  127. } catch (ParseException e) {
  128. }
  129. }
  130. d.setValidityPeriod(validityPeriod);
  131. d.setId(UUID.randomUUID().toString());
  132. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  133. Calendar now = Calendar.getInstance();
  134. now.set(Calendar.MILLISECOND, 0);
  135. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  136. d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
  137. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  138. d.setPrincipalId(TokenManager.getAdminId());
  139. if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
  140. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  141. createAuditorNotice(d);
  142. }
  143. d.setCreateTime(now.getTime());
  144. demandMapper.insert(d);
  145. disposeDemandKeyword(keywords, d, false);
  146. }
  147. @Override
  148. public int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
  149. Date validityPeriod = null;
  150. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  151. try {
  152. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  153. } catch (ParseException e) {
  154. }
  155. }
  156. d.setValidityPeriod(validityPeriod);
  157. if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
  158. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  159. createAuditorNotice(d);
  160. }
  161. disposeDemandKeyword(keywords, d, true);
  162. return demandMapper.updateByPrimaryKeySelective(d);
  163. }
  164. @Override
  165. public DemandManageDetailBo selectUserDemandDetail(String id) {
  166. return demandMapper.selectUserDemandDetail(id);
  167. }
  168. @Override
  169. public int deleteByPrimaryKey(List<String> id) {
  170. demandKeywordMapper.batchDeleteByDemandIds(id);
  171. achievementDemandMapper.batchDeleteByDemandIds(id);
  172. return demandMapper.batchDeleteByPrimaryKey(id);
  173. }
  174. @Override
  175. public DemandManageDetailBo selectOrgDemandDetail(String id) {
  176. return demandMapper.selectOrgDemandDetail(id);
  177. }
  178. @Override
  179. public Demand selectByPrimaryKey(String id) {
  180. return demandMapper.selectByPrimaryKey(id);
  181. }
  182. @SuppressWarnings("unchecked")
  183. @Override
  184. public Pagination<DemandListBo> listDemand(Integer auditStatus, Integer serialNumber, String name, String keyword,
  185. Integer demandType, String validityPeriodStartDate, String validityPeriodEndDate, Integer status,
  186. Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate, Integer pNo, Integer pSize) {
  187. Map<String, Object> params = disposeParams(auditStatus, null, serialNumber, name, keyword, null, demandType,
  188. validityPeriodStartDate, validityPeriodEndDate, null, status, releaseStatus, releaseDateStartDate,
  189. releaseDateEndDate);
  190. params.put("employerId", TokenManager.getUserId());
  191. if (pNo == null || pNo < 0) {
  192. pNo = 1;
  193. }
  194. if (pSize == null || pSize < 0) {
  195. pSize = 10;
  196. }
  197. return (Pagination<DemandListBo>) findPage("findDemandListByPage", "findDemandCount", params, pNo, pSize);
  198. }
  199. @Override
  200. public int updateReleaseStatus(Demand d) {
  201. d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
  202. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  203. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  204. demandMapper.updateReleaseDate(d.getId());
  205. demandKeywordMapper.batchDeleteByDemandId(d.getId());
  206. achievementDemandMapper.deleteByDemandId(d.getId());
  207. return demandMapper.updateByPrimaryKeySelective(d);
  208. }
  209. @Override
  210. public int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus) {
  211. d.setAuditStatus(auditStatus);
  212. if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)) {
  213. Calendar now = Calendar.getInstance();
  214. now.set(Calendar.MILLISECOND, 0);
  215. d.setReleaseDate(now.getTime());
  216. d.setReleaseStatus(DemandReleaseStatus.RELEASED.getCode());
  217. d.setTechBrokerId(techBroderId);
  218. } else {
  219. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  220. }
  221. createTechBorkerNotice(d);
  222. return demandMapper.updateByPrimaryKeySelective(d);
  223. }
  224. @Override
  225. public void saveDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
  226. Date validityPeriod = null;
  227. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  228. try {
  229. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  230. } catch (ParseException e) {
  231. }
  232. }
  233. d.setValidityPeriod(validityPeriod);
  234. d.setId(UUID.randomUUID().toString());
  235. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  236. Calendar now = Calendar.getInstance();
  237. now.set(Calendar.MILLISECOND, 0);
  238. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  239. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  240. if (DemandAuditStatus.SUBMIT.getCode().equals(d.getAuditStatus())) {
  241. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  242. createAuditorNotice(d);
  243. } else {
  244. d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
  245. }
  246. d.setCreateTime(now.getTime());
  247. demandMapper.insert(d);
  248. disposeDemandKeyword(keywords, d, false);
  249. }
  250. @Override
  251. public List<AchievementDemandListBo> selectAchievementDemandListByDemandId(String id) {
  252. return achievementDemandMapper.selectAchievementDemandListByDemandId(id);
  253. }
  254. @Override
  255. public void insertImport(List<DemandImportBo> data) {
  256. if (null == data || data.isEmpty()) {
  257. return;
  258. }
  259. Demand d = null;
  260. DemandKeyword dk = null;
  261. List<Demand> demandList = new ArrayList<>();
  262. List<DemandKeyword> demandKeywordList = new ArrayList<>();
  263. Calendar now = Calendar.getInstance();
  264. now.set(Calendar.MILLISECOND, 0);
  265. for (DemandImportBo bo : data) {
  266. d = new Demand();
  267. BeanUtils.copyProperties(bo, d);
  268. d.setId(UUID.randomUUID().toString());
  269. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  270. d.setCreateTime(now.getTime());
  271. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  272. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  273. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  274. d.setInfoSources(DemandInfoSourceStatus.IMPORT.getCode());
  275. List<String> keywordsList = bo.getKeywords();
  276. if (null != keywordsList && keywordsList.size() > 0) {
  277. for (String s : keywordsList) {
  278. if (!StringUtils.isBlank(s)) {
  279. dk = new DemandKeyword();
  280. dk.setDemandId(d.getId());
  281. dk.setKeyword(s.trim());
  282. dk.setId(UUID.randomUUID().toString());
  283. demandKeywordList.add(dk);
  284. }
  285. }
  286. }
  287. demandList.add(d);
  288. }
  289. demandMapper.insertBatch(demandList);
  290. demandKeywordMapper.insertBatch(demandKeywordList);
  291. }
  292. @SuppressWarnings("unchecked")
  293. @Override
  294. public Pagination<DemandSearchListBo> listDemandSearchList(String keyword, Integer industryCategoryA,
  295. Integer industryCategoryB, Integer demandType, BigDecimal budgetCostLower, BigDecimal budgetCostUpper,
  296. Integer pNo, Integer pSize) {
  297. Map<String, Object> params = new HashMap<>();
  298. if (!StringUtils.isBlank(keyword)) {
  299. params.put("keyword", keyword);
  300. }
  301. if (null != industryCategoryA) {
  302. params.put("industryCategoryA", industryCategoryA);
  303. }
  304. if (null != industryCategoryB) {
  305. params.put("industryCategoryB", industryCategoryB);
  306. }
  307. if (null != demandType) {
  308. params.put("demandType", demandType);
  309. }
  310. if (null != budgetCostLower) {
  311. params.put("budgetCostLower", budgetCostLower);
  312. }
  313. if (null != budgetCostUpper) {
  314. params.put("budgetCostUpper", budgetCostUpper);
  315. }
  316. if (pNo == null || pNo < 0) {
  317. pNo = 1;
  318. }
  319. if (pSize == null || pSize < 0 || pSize > 10) {
  320. pSize = 10;
  321. }
  322. return (Pagination<DemandSearchListBo>) findPage("findSearchDemandListByPage", "findSearchDemandCount", params,
  323. pNo, pSize);
  324. }
  325. @Override
  326. public DemandSearchDetailBo selectDemandSearchDetail(String uid, String id) {
  327. return demandMapper.selectDemandSearchDetail(uid, id);
  328. }
  329. private Map<String, Object> disposeParams(Integer auditStatus, Integer province, Integer serialNumber, String name,
  330. String keyword, Integer infoSources, Integer demandType, String validityPeriodStartDate,
  331. String validityPeriodEndDate, String username, Integer status, Integer releaseStatus,
  332. String releaseDateStartDate, String releaseDateEndDate) {
  333. Map<String, Object> params = new HashMap<>();
  334. Date vStart = null;
  335. Date vEnd = null;
  336. Date rStart = null;
  337. Date rEnd = null;
  338. if (!StringUtils.isBlank(validityPeriodStartDate)) {
  339. try {
  340. vStart = DateUtils.parseDate(validityPeriodStartDate, AFTConstants.YYYYMMDD);
  341. } catch (ParseException e) {
  342. }
  343. }
  344. if (!StringUtils.isBlank(validityPeriodEndDate)) {
  345. try {
  346. vEnd = DateUtils.parseDate(validityPeriodEndDate, AFTConstants.YYYYMMDD);
  347. } catch (ParseException e) {
  348. }
  349. }
  350. if (!StringUtils.isBlank(releaseDateStartDate)) {
  351. try {
  352. rStart = DateUtils.parseDate(releaseDateStartDate, AFTConstants.YYYYMMDD);
  353. } catch (ParseException e) {
  354. }
  355. }
  356. if (!StringUtils.isBlank(releaseDateEndDate)) {
  357. try {
  358. rEnd = DateUtils.parseDate(releaseDateEndDate, AFTConstants.YYYYMMDD);
  359. } catch (ParseException e) {
  360. }
  361. }
  362. if (null != vStart) {
  363. params.put("vStart", vStart);
  364. }
  365. if (null != vEnd) {
  366. params.put("vEnd", vEnd);
  367. }
  368. if (null != rStart) {
  369. params.put("rStart", rStart);
  370. }
  371. if (null != rEnd) {
  372. params.put("rEnd", rEnd);
  373. }
  374. if (null != auditStatus) {
  375. params.put("auditStatus", auditStatus);
  376. }
  377. if (null != province) {
  378. params.put("province", province);
  379. }
  380. if (null != serialNumber) {
  381. params.put("serialNumber", serialNumber);
  382. }
  383. if (!StringUtils.isBlank(name)) {
  384. params.put("name", name);
  385. }
  386. if (!StringUtils.isBlank(keyword)) {
  387. params.put("keyword", keyword);
  388. }
  389. if (!StringUtils.isBlank(username)) {
  390. params.put("username", username);
  391. }
  392. if (null != infoSources) {
  393. params.put("infoSources", infoSources);
  394. }
  395. if (null != demandType) {
  396. params.put("demandType", demandType);
  397. }
  398. if (null != status) {
  399. params.put("status", status);
  400. }
  401. if (null != releaseStatus) {
  402. params.put("releaseStatus", releaseStatus);
  403. }
  404. return params;
  405. }
  406. // 给所有审核员发送审核通知
  407. private void createAuditorNotice(Demand d) {
  408. List<String> ids = userRoleMapper.listAuditor();
  409. List<Notice> list = new ArrayList<>();
  410. if (null != ids && ids.size() > 0) {
  411. for (String s : ids) {
  412. list.add(disposeNotice(d, s));
  413. }
  414. noticeMapper.insertBatch(list);
  415. }
  416. }
  417. // 给指派技术经纪人发送审核结果通知
  418. private void createTechBorkerNotice(Demand a) {
  419. noticeMapper.insert(disposeNotice(a, null));
  420. }
  421. private Notice disposeNotice(Demand d, String aid) {
  422. Notice n = new Notice();
  423. Calendar now = Calendar.getInstance();
  424. now.set(Calendar.MILLISECOND, 0);
  425. n.setId(UUID.randomUUID().toString());
  426. n.setCreateTime(now.getTime());
  427. n.setReaded(NoticeReadStatus.UNREAD.getCode());
  428. n.setRid(d.getId());
  429. User u = userMapper.selectByPrimaryKey(d.getEmployerId());
  430. if (null != u) {
  431. n.setPid(u.getAid());
  432. }
  433. if (StringUtils.isBlank(aid)) {
  434. n.setAid(d.getTechBrokerId());
  435. if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
  436. n.setContent("编号" + d.getSerialNumber() + NoticeStatus.PERSONALDEMAND.getDesc() + " "
  437. + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
  438. ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
  439. n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
  440. } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
  441. n.setContent("编号" + d.getSerialNumber() + NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " "
  442. + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
  443. ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
  444. n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
  445. }
  446. } else {
  447. n.setAid(aid);
  448. if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
  449. n.setContent(NoticeStatus.PERSONALDEMAND.getDesc() + " " + DemandAuditStatus.SUBMIT.getDesc());
  450. n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
  451. } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
  452. n.setContent(NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " " + DemandAuditStatus.SUBMIT.getDesc());
  453. n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
  454. }
  455. }
  456. return n;
  457. }
  458. private void disposeDemandKeyword(String[] keywords, Demand d, boolean delete) {
  459. if (null != keywords && keywords.length > 0) {
  460. if (delete) {
  461. demandKeywordMapper.batchDeleteByDemandId(d.getId());
  462. }
  463. List<DemandKeyword> list = new ArrayList<>();
  464. DemandKeyword dk = null;
  465. for (int i = 0; i < keywords.length; i++) {
  466. dk = new DemandKeyword();
  467. dk.setId(UUID.randomUUID().toString());
  468. dk.setDemandId(d.getId());
  469. dk.setKeyword(keywords[i].trim());
  470. list.add(dk);
  471. }
  472. demandKeywordMapper.insertBatch(list);
  473. }
  474. }
  475. @Override
  476. public int updateMatchAchievement(Demand d) {
  477. achievementDemandMapper.deleteByDemandId(d.getId());
  478. List<DemandKeyword> demand = demandKeywordMapper.selectKeywordsByDemandId(d.getId());
  479. if (null != demand && demand.size() > 0) {
  480. List<String> keyword = new ArrayList<>();
  481. for (DemandKeyword k : demand) {
  482. if (!StringUtils.isBlank(k.getKeyword())) {
  483. keyword.add(k.getKeyword());
  484. }
  485. }
  486. List<AchievementDemand> list = achievementKeywordMapper.selectAchievementDemand(keyword);
  487. if (null != list && list.size() > 0) {
  488. for (AchievementDemand ad : list) {
  489. ad.setDemandId(d.getId());
  490. }
  491. return achievementDemandMapper.insertBatch(list);
  492. }
  493. }
  494. return 0;
  495. }
  496. @SuppressWarnings("unchecked")
  497. @Override
  498. public Pagination<DemandPartnerListBo> lisePartnerDemand(String employerId, Integer pNo, Integer pSize) {
  499. Map<String, Object> params = new HashMap<>();
  500. params.put("employerId", employerId);
  501. if (pNo == null || pNo < 0) {
  502. pNo = 1;
  503. }
  504. if (pSize == null || pSize < 0 || pSize > 10) {
  505. pSize = 10;
  506. }
  507. return (Pagination<DemandPartnerListBo>) findPage("findPartnerDemandListByPage", "findPartnerDemandCount",
  508. params, pNo, pSize);
  509. }
  510. @Override
  511. public DemandPortalDetailBo findUserPortalDemandDetail(String id) {
  512. return demandMapper.findUserPortalDemandDetail(id);
  513. }
  514. @Override
  515. public DemandPortalDetailBo findOrgPortalDemandDetail(String id) {
  516. return demandMapper.findOrgPortalDemandDetail(id);
  517. }
  518. @Override
  519. public List<DemandPortalSimilarListBo> findByIndustryCategoryA(Integer industryCategoryA, String id) {
  520. return demandMapper.findByIndustryCategoryA(industryCategoryA, id);
  521. }
  522. }