DemandServiceImpl.java 26 KB

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