DemandServiceImpl.java 20 KB

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