DemandServiceImpl.java 22 KB

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