DemandServiceImpl.java 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  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.apache.poi.ss.usermodel.Cell;
  13. import org.apache.poi.ss.usermodel.Row;
  14. import org.apache.poi.ss.usermodel.Sheet;
  15. import org.springframework.beans.BeanUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.beans.factory.annotation.Value;
  18. import org.springframework.stereotype.Service;
  19. import org.springframework.web.multipart.MultipartFile;
  20. import com.goafanti.common.bo.Error;
  21. import com.goafanti.common.bo.MyCollection;
  22. import com.goafanti.common.constant.AFTConstants;
  23. import com.goafanti.common.constant.PageConstants;
  24. import com.goafanti.common.dao.AchievementDemandCountMapper;
  25. import com.goafanti.common.dao.AchievementDemandMapper;
  26. import com.goafanti.common.dao.AchievementKeywordMapper;
  27. import com.goafanti.common.dao.AchievementMapper;
  28. import com.goafanti.common.dao.BranchInformationMapper;
  29. import com.goafanti.common.dao.DemandFollowDetailMapper;
  30. import com.goafanti.common.dao.DemandInterestMapper;
  31. import com.goafanti.common.dao.DemandKeywordMapper;
  32. import com.goafanti.common.dao.DemandMapper;
  33. import com.goafanti.common.dao.DemandPublishMapper;
  34. import com.goafanti.common.dao.FieldGlossoryMapper;
  35. import com.goafanti.common.dao.JtCollectSearchMapper;
  36. import com.goafanti.common.dao.NewsInterestMapper;
  37. import com.goafanti.common.dao.NoticeMapper;
  38. import com.goafanti.common.dao.OrganizationIdentityMapper;
  39. import com.goafanti.common.dao.ProjectInterestMapper;
  40. import com.goafanti.common.dao.UserIdentityMapper;
  41. import com.goafanti.common.dao.UserInterestMapper;
  42. import com.goafanti.common.dao.UserMapper;
  43. import com.goafanti.common.dao.UserRoleMapper;
  44. import com.goafanti.common.enums.AchievementAuditStatus;
  45. import com.goafanti.common.enums.DeleteStatus;
  46. import com.goafanti.common.enums.DemandAuditStatus;
  47. import com.goafanti.common.enums.DemandInfoSourceStatus;
  48. import com.goafanti.common.enums.DemandReleaseStatus;
  49. import com.goafanti.common.enums.DemandStatus;
  50. import com.goafanti.common.enums.InterestType;
  51. import com.goafanti.common.enums.NoticeReadStatus;
  52. import com.goafanti.common.enums.NoticeStatus;
  53. import com.goafanti.common.enums.UserType;
  54. import com.goafanti.common.enums.collectType;
  55. import com.goafanti.common.error.BusinessException;
  56. import com.goafanti.common.model.AchievementDemand;
  57. import com.goafanti.common.model.AchievementDemandCount;
  58. import com.goafanti.common.model.Demand;
  59. import com.goafanti.common.model.DemandKeyword;
  60. import com.goafanti.common.model.DemandPublish;
  61. import com.goafanti.common.model.JtCollectSearch;
  62. import com.goafanti.common.model.Notice;
  63. import com.goafanti.common.model.OrganizationIdentity;
  64. import com.goafanti.common.model.User;
  65. import com.goafanti.common.model.UserIdentity;
  66. import com.goafanti.common.utils.DateUtils;
  67. import com.goafanti.common.utils.FileUtils;
  68. import com.goafanti.core.mybatis.BaseMybatisDao;
  69. import com.goafanti.core.mybatis.page.Pagination;
  70. import com.goafanti.core.shiro.token.TokenManager;
  71. import com.goafanti.demand.bo.AppDemandBo;
  72. import com.goafanti.demand.bo.DemandDetailBo;
  73. import com.goafanti.demand.bo.DemandImportBo;
  74. import com.goafanti.demand.bo.DemandListBo;
  75. import com.goafanti.demand.bo.ObjectInterestListBo;
  76. import com.goafanti.demand.service.DemandService;
  77. import com.goafanti.portal.bo.DemandSearchDetailBo;
  78. import com.goafanti.portal.bo.DemandSearchListBo;
  79. @Service
  80. public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements DemandService {
  81. @Autowired
  82. private DemandMapper demandMapper;
  83. @Autowired
  84. private UserMapper userMapper;
  85. @Autowired
  86. private UserRoleMapper userRoleMapper;
  87. @Autowired
  88. private NoticeMapper noticeMapper;
  89. @Autowired
  90. private DemandKeywordMapper demandKeywordMapper;
  91. @Autowired
  92. private AchievementDemandMapper achievementDemandMapper;
  93. @Autowired
  94. private AchievementKeywordMapper achievementKeywordMapper;
  95. @Autowired
  96. private AchievementDemandCountMapper achievementDemandCountMapper;
  97. @Autowired
  98. private UserIdentityMapper userIdentityMapper;
  99. @Autowired
  100. private OrganizationIdentityMapper organizationIdentityMapper;
  101. @Autowired
  102. private AchievementMapper achievementMapper;
  103. @Autowired
  104. private DemandInterestMapper demandInterestMapper;
  105. @Autowired
  106. private NewsInterestMapper newsInterestMapper;
  107. @Autowired
  108. private UserInterestMapper userInterestMapper;
  109. @Autowired
  110. ProjectInterestMapper projectInterestMapper;
  111. @Autowired
  112. DemandFollowDetailMapper demandFollowDetailMapper;
  113. @Autowired
  114. FieldGlossoryMapper fieldGlossoryMapper;
  115. @Autowired
  116. BranchInformationMapper branchInformationMapper;
  117. @Autowired
  118. DemandPublishMapper demandPublishMapper;
  119. @Autowired
  120. JtCollectSearchMapper jtCollectSearchMapper;
  121. @Value(value="${collect_flag}")
  122. private Boolean collectFlag ;
  123. @Override
  124. public int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords,List<String> webPages,List<String> appPages) {
  125. Date validityPeriod = null;
  126. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  127. try {
  128. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  129. } catch (ParseException e) {
  130. }
  131. }
  132. d.setValidityPeriod(validityPeriod);
  133. disposeDemandKeyword(keywords, d, true);
  134. disposeDemandPublish(d,webPages,appPages,true);
  135. demandMapper.updateByPrimaryKeySelective(d);
  136. return 1;
  137. }
  138. @Override
  139. public DemandDetailBo selectUserDemandDetail(String id) {
  140. return demandMapper.selectUserDemandDetail(id);
  141. }
  142. @Override
  143. public int deleteByPrimaryKey(List<String> id) {
  144. demandKeywordMapper.batchDeleteByDemandIds(id);
  145. achievementDemandMapper.batchDeleteByDemandIds(id);
  146. demandPublishMapper.batchDeleteByDemandIds(id);
  147. for (String s : id) {
  148. Demand d = demandMapper.selectByPrimaryKey(s);
  149. if(collectFlag)jtCollectSearchMapper.deleteByrowId(s);
  150. if (null != d && DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
  151. && StringUtils.isNotBlank(d.getEmployerId())) {
  152. AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(d.getEmployerId());
  153. if (null != adc) {
  154. adc.setDemandCount(adc.getDemandCount() - 1);
  155. if (adc.getDemandCount() < 0) {
  156. adc.setDemandCount(0);
  157. }
  158. achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
  159. }
  160. }
  161. }
  162. return demandMapper.batchDeleteByPrimaryKey(id);
  163. }
  164. @Override
  165. public DemandDetailBo selectOrgDemandDetail(String id) {
  166. return demandMapper.selectOrgDemandDetail(id);
  167. }
  168. @Override
  169. public Demand selectByPrimaryKey(String id) {
  170. return demandMapper.selectByPrimaryKey(id);
  171. }
  172. @Override
  173. public int updateReleaseStatus(Demand d) {
  174. d.setAuditStatus(DemandAuditStatus.AUDITED.getCode());
  175. if(d.getReleaseStatus()==1){
  176. Calendar now = Calendar.getInstance();
  177. now.set(Calendar.MILLISECOND, 0);
  178. d.setReleaseDate(now.getTime());
  179. }
  180. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  181. d.setAuditStatus(DemandAuditStatus.REVOKE.getCode());
  182. int i=0;
  183. i=demandMapper.updateByPrimaryKeySelective(d);
  184. if(collectFlag)jtCollectSearchMapper.deleteByrowId(d.getId());
  185. demandKeywordMapper.batchDeleteByDemandId(d.getId());
  186. achievementDemandMapper.deleteByDemandId(d.getId());
  187. if (StringUtils.isNotBlank(d.getEmployerId())) {
  188. AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(d.getEmployerId());
  189. if (null != adc) {
  190. adc.setDemandCount(adc.getDemandCount() - 1);
  191. if (adc.getDemandCount() < 0) {
  192. adc.setDemandCount(0);
  193. }
  194. achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
  195. }
  196. }
  197. disposeDemandPublish(d, null, null, true);
  198. return i;
  199. }
  200. @Override
  201. public int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus) {
  202. d.setAuditStatus(auditStatus);
  203. if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)) {
  204. Calendar now = Calendar.getInstance();
  205. now.set(Calendar.MILLISECOND, 0);
  206. d.setReleaseDate(now.getTime());
  207. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  208. d.setTechBrokerId(techBroderId);
  209. if (StringUtils.isNotBlank(d.getKeyword())) {
  210. String[] keywords = d.getKeyword().trim().split(",|,");
  211. disposeDemandKeyword(keywords, d, false);
  212. }
  213. String employerId = d.getEmployerId();
  214. if (StringUtils.isNotBlank(employerId)) {
  215. if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
  216. UserIdentity ui = userIdentityMapper.selectUserIdentityByUserId(employerId);
  217. if (null != ui) {
  218. d.setEmployerName(ui.getUsername());
  219. }
  220. } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
  221. OrganizationIdentity oi = organizationIdentityMapper.selectOrgIdentityByUserId(employerId);
  222. if (null != oi) {
  223. d.setEmployerName(oi.getUnitName());
  224. }
  225. }
  226. AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(employerId);
  227. if (null == adc) {
  228. AchievementDemandCount achievementDemandCount = new AchievementDemandCount();
  229. achievementDemandCount.setId(UUID.randomUUID().toString());
  230. achievementDemandCount.setUid(employerId);
  231. achievementDemandCount.setDemandCount(AFTConstants.ACHIEVEMENT_DEMAND_FIRST_COUNT);
  232. achievementDemandCount.setAchievementCount(AFTConstants.ACHIEVEMENT_DEMAND_INIT_COUNT);
  233. achievementDemandCountMapper.insert(achievementDemandCount);
  234. } else {
  235. adc.setDemandCount(adc.getDemandCount() + 1);
  236. achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
  237. }
  238. }
  239. } else {
  240. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  241. }
  242. createTechBorkerNotice(d);
  243. return demandMapper.updateByPrimaryKeySelective(d);
  244. }
  245. @Override
  246. public void saveDemand(Demand d, String validityPeriodFormattedDate, String[] keywords,List<String> webPages, List<String> appPages) {
  247. Date validityPeriod = null;
  248. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  249. try {
  250. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  251. } catch (ParseException e) {
  252. }
  253. }
  254. d.setValidityPeriod(validityPeriod);
  255. d.setId(UUID.randomUUID().toString());
  256. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  257. Calendar now = Calendar.getInstance();
  258. now.set(Calendar.MILLISECOND, 0);
  259. // d.setStatus(DemandStatus.UNRESOLVED.getCode());
  260. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  261. d.setInfoSources(1);
  262. if (DemandAuditStatus.INAUDIT.getCode().equals(d.getAuditStatus())) {
  263. createAuditorNotice(d);
  264. // d.setReleaseDate(new Date());
  265. } else {
  266. d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
  267. }
  268. d.setCreateTime(now.getTime());
  269. demandMapper.insert(d);
  270. disposeDemandKeyword(keywords, d, false);
  271. disposeDemandPublish(d,webPages,appPages,false);
  272. }
  273. @Override
  274. public void insertImport(List<DemandImportBo> data) {
  275. if (null == data || data.isEmpty()) {
  276. return;
  277. }
  278. Demand d = null;
  279. DemandKeyword dk = null;
  280. List<Demand> demandList = new ArrayList<>();
  281. List<DemandKeyword> demandKeywordList = new ArrayList<>();
  282. Calendar now = Calendar.getInstance();
  283. now.set(Calendar.MILLISECOND, 0);
  284. String techBrokerId = TokenManager.getAdminId();
  285. for (DemandImportBo bo : data) {
  286. d = new Demand();
  287. BeanUtils.copyProperties(bo, d);
  288. d.setId(UUID.randomUUID().toString());
  289. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  290. d.setCreateTime(now.getTime());
  291. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  292. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  293. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  294. d.setInfoSources(DemandInfoSourceStatus.IMPORT.getCode());
  295. d.setTechBrokerId(techBrokerId);
  296. List<String> keywordsList = bo.getKeywords();
  297. if (null != keywordsList && keywordsList.size() > 0) {
  298. for (String s : keywordsList) {
  299. if (!StringUtils.isBlank(s)) {
  300. dk = new DemandKeyword();
  301. dk.setDemandId(d.getId());
  302. dk.setKeyword(s.trim());
  303. dk.setId(UUID.randomUUID().toString());
  304. demandKeywordList.add(dk);
  305. }
  306. }
  307. }
  308. demandList.add(d);
  309. }
  310. demandMapper.insertBatch(demandList);
  311. demandKeywordMapper.insertBatch(demandKeywordList);
  312. }
  313. @Override
  314. public DemandSearchDetailBo selectDemandDetail(String uid, String id) {
  315. return demandMapper.selectDemandDetail(uid, id);
  316. }
  317. private Map<String, Object> disposeParams(Integer auditStatus, Integer province, Integer serialNumber, String name,
  318. String keyword, Integer infoSources, Integer demandType, String validityPeriodStartDate,
  319. String validityPeriodEndDate, String username, Integer status, Integer releaseStatus,
  320. String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer boutique, Integer hot) {
  321. Map<String, Object> params = new HashMap<>();
  322. Date vStart = null;
  323. Date vEnd = null;
  324. Date rStart = null;
  325. Date rEnd = null;
  326. Date cStart = null;
  327. Date cEnd = null;
  328. if (!StringUtils.isBlank(validityPeriodStartDate)) {
  329. try {
  330. vStart = DateUtils.parseDate(validityPeriodStartDate, AFTConstants.YYYYMMDD);
  331. } catch (ParseException e) {
  332. }
  333. }
  334. if (!StringUtils.isBlank(validityPeriodEndDate)) {
  335. try {
  336. vEnd = DateUtils.addDays(DateUtils.parseDate(validityPeriodEndDate, AFTConstants.YYYYMMDD), 1);
  337. } catch (ParseException e) {
  338. }
  339. }
  340. if (!StringUtils.isBlank(releaseDateStartDate)) {
  341. try {
  342. rStart = DateUtils.parseDate(releaseDateStartDate, AFTConstants.YYYYMMDD);
  343. } catch (ParseException e) {
  344. }
  345. }
  346. if (!StringUtils.isBlank(releaseDateEndDate)) {
  347. try {
  348. rEnd = DateUtils.addDays(DateUtils.parseDate(releaseDateEndDate, AFTConstants.YYYYMMDD), 1);
  349. } catch (ParseException e) {
  350. }
  351. }
  352. if (!StringUtils.isBlank(createDateStartDate)) {
  353. try {
  354. cStart = DateUtils.parseDate(createDateStartDate, AFTConstants.YYYYMMDD);
  355. } catch (ParseException e) {
  356. }
  357. }
  358. if (!StringUtils.isBlank(createDateEndDate)) {
  359. try {
  360. cEnd = DateUtils.addDays(DateUtils.parseDate(createDateEndDate, AFTConstants.YYYYMMDD), 1);
  361. } catch (ParseException e) {
  362. }
  363. }
  364. if (null != vStart) {
  365. params.put("vStart", vStart);
  366. }
  367. if (null != vEnd) {
  368. params.put("vEnd", vEnd);
  369. }
  370. if (null != rStart) {
  371. params.put("rStart", rStart);
  372. }
  373. if (null != rEnd) {
  374. params.put("rEnd", rEnd);
  375. }
  376. if (null != cStart) {
  377. params.put("cStart", cStart);
  378. }
  379. if (null != cEnd) {
  380. params.put("cEnd", cEnd);
  381. }
  382. if (null != auditStatus) {
  383. params.put("auditStatus", auditStatus);
  384. }
  385. if (null != province) {
  386. params.put("province", province);
  387. }
  388. if (null != serialNumber) {
  389. params.put("serialNumber", serialNumber);
  390. }
  391. if (!StringUtils.isBlank(name)) {
  392. params.put("name", name);
  393. }
  394. if (!StringUtils.isBlank(keyword)) {
  395. params.put("keyword", keyword);
  396. }
  397. /*
  398. * if (!StringUtils.isBlank(username)) { params.put("username",
  399. * username); }
  400. */
  401. if (null != infoSources) {
  402. params.put("infoSources", infoSources);
  403. }
  404. if (null != demandType) {
  405. params.put("demandType", demandType);
  406. }
  407. if (null != status) {
  408. params.put("status", status);
  409. }
  410. if (null != releaseStatus) {
  411. params.put("releaseStatus", releaseStatus);
  412. }
  413. if (null != boutique) {
  414. params.put("boutique", boutique);
  415. }
  416. if (null != hot) {
  417. params.put("hot", hot);
  418. }
  419. return params;
  420. }
  421. // 给所有审核员发送审核通知
  422. private void createAuditorNotice(Demand d) {
  423. List<String> ids = userRoleMapper.listAuditor();
  424. List<Notice> list = new ArrayList<>();
  425. if (null != ids && ids.size() > 0) {
  426. for (String s : ids) {
  427. list.add(disposeNotice(d, s));
  428. }
  429. noticeMapper.insertBatch(list);
  430. }
  431. }
  432. // 给指派技术经纪人发送审核结果通知
  433. private void createTechBorkerNotice(Demand a) {
  434. // noticeMapper.insert(disposeNotice(a, null));
  435. }
  436. private Notice disposeNotice(Demand d, String aid) {
  437. Notice n = new Notice();
  438. Calendar now = Calendar.getInstance();
  439. now.set(Calendar.MILLISECOND, 0);
  440. n.setId(UUID.randomUUID().toString());
  441. n.setCreateTime(now.getTime());
  442. n.setReaded(NoticeReadStatus.UNREAD.getCode());
  443. n.setRid(d.getId());
  444. User u = userMapper.selectByPrimaryKey(d.getEmployerId());
  445. if (null != u) {
  446. n.setPid(u.getAid());
  447. }
  448. if (StringUtils.isBlank(aid)) {
  449. n.setAid(d.getTechBrokerId());
  450. if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
  451. n.setContent("编号" + d.getSerialNumber() + NoticeStatus.PERSONALDEMAND.getDesc() + " "
  452. + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
  453. ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
  454. n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
  455. } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
  456. n.setContent("编号" + d.getSerialNumber() + NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " "
  457. + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
  458. ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
  459. n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
  460. }
  461. } else {
  462. n.setAid(aid);
  463. if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
  464. n.setContent(NoticeStatus.PERSONALDEMAND.getDesc() + " " + DemandAuditStatus.INAUDIT.getDesc());
  465. n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
  466. } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
  467. n.setContent(NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " " + DemandAuditStatus.INAUDIT.getDesc());
  468. n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
  469. }
  470. }
  471. return n;
  472. }
  473. private void disposeDemandPublish(Demand d,List<String> webPages,List<String> appPages,boolean delete){
  474. if(delete){
  475. if(null != webPages && webPages.size()>0){
  476. demandPublishMapper.deleteByDemandId(d.getId());
  477. }
  478. }
  479. DemandPublish dp = null;
  480. String defaultPlatformId = branchInformationMapper.selectByDomain(PageConstants.DEFAULT_DOMAIN).getId();
  481. if(webPages != null && webPages.size()>0){
  482. for(String page: webPages){
  483. dp = new DemandPublish();
  484. dp.setId(UUID.randomUUID().toString());
  485. dp.setDemandId(d.getId());
  486. dp.setPublisher(TokenManager.getUserId());
  487. // dp.setPublisher("1");
  488. dp.setPublishTime(d.getReleaseDate()==null?new Date():d.getReleaseDate());
  489. dp.setPublishClient(PageConstants.WEB_PLATFORM);
  490. dp.setPublishPage(page);
  491. dp.setPublishPlatform(defaultPlatformId);
  492. dp.setIfTop(AFTConstants.NO);
  493. dp.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
  494. dp.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
  495. demandPublishMapper.insert(dp);
  496. }
  497. }
  498. if(appPages != null && appPages.size()>0){
  499. for(String page: appPages){
  500. dp = new DemandPublish();
  501. dp.setId(UUID.randomUUID().toString());
  502. dp.setDemandId(d.getId());
  503. dp.setPublisher(TokenManager.getUserId());
  504. // dp.setPublisher("1");
  505. dp.setPublishTime(d.getReleaseDate()==null?new Date():d.getReleaseDate());
  506. dp.setPublishClient(PageConstants.APP_PLATFORM);
  507. dp.setPublishPage(page);
  508. dp.setPublishPlatform(defaultPlatformId);
  509. dp.setIfTop(AFTConstants.NO);
  510. dp.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
  511. dp.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
  512. demandPublishMapper.insert(dp);
  513. }
  514. }
  515. }
  516. private void disposeDemandKeyword(String[] keywords, Demand d, boolean delete) {
  517. if (null != keywords && keywords.length > 0) {
  518. if (delete) {
  519. demandKeywordMapper.batchDeleteByDemandId(d.getId());
  520. }
  521. List<DemandKeyword> list = new ArrayList<>();
  522. DemandKeyword dk = null;
  523. for (int i = 0; i < keywords.length; i++) {
  524. dk = new DemandKeyword();
  525. dk.setId(UUID.randomUUID().toString());
  526. dk.setDemandId(d.getId());
  527. dk.setKeyword(keywords[i].trim());
  528. list.add(dk);
  529. }
  530. demandKeywordMapper.insertBatch(list);
  531. }
  532. }
  533. @Override
  534. public int updateMatchAchievement(Demand d) {
  535. achievementDemandMapper.deleteByDemandId(d.getId());
  536. List<DemandKeyword> demand = demandKeywordMapper.selectKeywordsByDemandId(d.getId());
  537. if (null != demand && demand.size() > 0) {
  538. List<String> keyword = new ArrayList<>();
  539. for (DemandKeyword k : demand) {
  540. if (!StringUtils.isBlank(k.getKeyword())) {
  541. keyword.add(k.getKeyword());
  542. }
  543. }
  544. List<AchievementDemand> list = achievementKeywordMapper.selectAchievementDemand(keyword);
  545. if (null != list && list.size() > 0) {
  546. for (AchievementDemand ad : list) {
  547. ad.setDemandId(d.getId());
  548. }
  549. return achievementDemandMapper.insertBatch(list);
  550. }
  551. }
  552. return 0;
  553. }
  554. @Override
  555. public int updateByPrimaryKeySelective(Demand d) {
  556. int i=demandMapper.updateByPrimaryKeySelective(d);
  557. if(collectFlag && null != d.getStatus()){
  558. if (d.getAuditStatus()==2) {
  559. JtCollectSearch r=new JtCollectSearch();
  560. r.setFromTable(collectType.DMAND.getDesc());
  561. r.setKeyword(d.getKeyword());
  562. r.setTitle(d.getName());
  563. r.setRowId(d.getId());
  564. String sum = d.getProblemDes();
  565. if(null != sum && sum.length() > 40){
  566. sum = sum.substring(0,40) + "...";
  567. }
  568. r.setSummary(sum);
  569. jtCollectSearchMapper.insertSelective(r);
  570. }
  571. if (d.getAuditStatus()==4||d.getAuditStatus()==3) {
  572. if(collectFlag)jtCollectSearchMapper.deleteByrowId(d.getId());
  573. }
  574. }
  575. return i;
  576. }
  577. @Override
  578. public AppDemandBo selectAppDemandDetail(String id ) {
  579. String uid=TokenManager.getUserId();
  580. //uid="0261d476-8336-4a0b-97d7-83c89e286852";
  581. return demandMapper.selectAppByPrimaryKey(id,uid);
  582. }
  583. @SuppressWarnings("unchecked")
  584. @Override
  585. public Pagination<ObjectInterestListBo> selectinterest(Integer type,Integer pNo, Integer pSize) {
  586. Map<String, Object> params=new HashMap<>();
  587. params.put("type", type);
  588. if (StringUtils.isNotBlank(TokenManager.getUserId())) {
  589. params.put("uid", TokenManager.getUserId());
  590. }
  591. //params.put("uid", "6d71349c-7bb8-4e8a-8c03-0c3f36fc66ae");
  592. if (type==InterestType.POLICY.getCode()) {
  593. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppNewsInterestByPage", "findAppNewsInterestCount", params, pNo, pSize);
  594. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  595. for (ObjectInterestListBo o : l) {
  596. int i=newsInterestMapper.countInterest(o.getId());
  597. o.setCountInterest(String.valueOf(i));
  598. o.setType(type);
  599. }
  600. return p;
  601. }
  602. if (type==InterestType.EXPERTS.getCode()) {
  603. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppUserInterestByPage", "findAppUserInterestCount", params, pNo, pSize);
  604. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  605. for (ObjectInterestListBo o : l) {
  606. int i=userInterestMapper.countInterest(o.getId());
  607. o.setCountInterest(String.valueOf(i));
  608. o.setType(type);
  609. }
  610. return p;
  611. }
  612. if (type==InterestType.DEMAND.getCode()) {
  613. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppDemandInterestByPage", "findAppDemandInterestCount", params, pNo, pSize);
  614. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  615. for (ObjectInterestListBo o : l) {
  616. int i=demandInterestMapper.checkCount(o.getId());
  617. o.setCountInterest(String.valueOf(i));
  618. o.setType(type);
  619. }
  620. return p;
  621. }
  622. if (null==type||type==InterestType.ACHIEVEMENT.getCode()) {
  623. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppAchievementInterestByPage", "findAppAchievementInterestCount", params, pNo, pSize);
  624. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  625. for (ObjectInterestListBo o : l) {
  626. int i=achievementMapper.countInterest(o.getId());
  627. o.setCountInterest(String.valueOf(i));
  628. o.setType(type);
  629. }
  630. return p;
  631. }
  632. if (null==type||type==InterestType.PROJECT.getCode()) {
  633. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppProjectInterestByPage", "findAppProjectInterestCount", params, pNo, pSize);
  634. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  635. for (ObjectInterestListBo o : l) {
  636. int i=projectInterestMapper.countInterest(o.getId());
  637. o.setCountInterest(String.valueOf(i));
  638. o.setType(type);
  639. }
  640. return p;
  641. }
  642. if (type==InterestType.COUNSELOR.getCode()) {
  643. Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppCounselorInterestByPage", "findAppCounselorInterestCount", params, pNo, pSize);
  644. List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
  645. for (ObjectInterestListBo o : l) {
  646. int i=userInterestMapper.countInterest(o.getId());
  647. o.setCountInterest(String.valueOf(i));
  648. o.setType(type);
  649. }
  650. return p;
  651. }
  652. return null;
  653. }
  654. @SuppressWarnings("unchecked")
  655. @Override
  656. public Pagination<AppDemandBo> listMyDemand(Integer pNo, Integer pSize) {
  657. Map<String, Object> params = new HashMap<>();
  658. if (pNo == null || pNo < 0) pNo = 1;
  659. if (pSize == null || pSize < 0) pSize = 10;
  660. if (StringUtils.isNotBlank(TokenManager.getUserId())) params.put("employerId", TokenManager.getUserId());
  661. //params.put("employerId", "46433140-0a90-471e-a32f-6bc89c562e3d");
  662. return (Pagination<AppDemandBo>) findPage("findAppMyDemandListByPage", "findAppMyDemandCount", params, pNo, pSize);
  663. }
  664. public int saveAppUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
  665. Date validityPeriod = null;
  666. if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
  667. try {
  668. validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
  669. } catch (ParseException e) {
  670. }
  671. }
  672. d.setInfoSources(1);
  673. if (null!=TokenManager.getUserId()) {
  674. d.setEmployerId(TokenManager.getUserId());
  675. User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
  676. if (null!=u.getType()) {
  677. d.setDataCategory(u.getType());
  678. }
  679. if (StringUtils.isNotBlank(u.getId())) {
  680. d.setEmployerId(u.getId());
  681. }
  682. if (StringUtils.isNotBlank(u.getMobile())) {
  683. d.setEmployerContactsMobile(u.getMobile());
  684. }
  685. }
  686. d.setValidityPeriod(validityPeriod);
  687. d.setId(UUID.randomUUID().toString());
  688. d.setTechBrokerId(TokenManager.getAdminId());
  689. d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  690. Calendar now = Calendar.getInstance();
  691. now.set(Calendar.MILLISECOND, 0);
  692. d.setStatus(DemandStatus.UNRESOLVED.getCode());
  693. d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
  694. d.setPrincipalId(TokenManager.getAdminId());
  695. d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
  696. createAuditorNotice(d);
  697. if (null==d.getKeyword()) {
  698. d.setKeyword("");
  699. }
  700. d.setCreateTime(now.getTime());
  701. disposeDemandKeyword(keywords, d, false);
  702. return demandMapper.insert(d);
  703. }
  704. @Override
  705. public Demand DemandFollowDetails(String id) {
  706. return demandMapper.selectDemandFollow(id);
  707. }
  708. @Override
  709. public List<DemandListBo> recentDemand(int size,String pattern,String showLocation) {
  710. return demandMapper.selectRecentDemand(size,pattern,showLocation);
  711. }
  712. @Override
  713. public List<DemandListBo> companyDemand(int size,String pattern,String showLocation) {
  714. return demandMapper.selectCompanyDemand(size,pattern,showLocation);
  715. }
  716. @Override
  717. public List<DemandListBo> getUrgentDemand(int size,String pattern,String showLocation) {
  718. return demandMapper.getUrgentDemand(size,pattern,showLocation);
  719. }
  720. @Override
  721. public List<DemandListBo> getHotDemand(int size,String pattern,String showLocation, int deletedSign) {
  722. return demandMapper.getHotDemand(size,pattern,showLocation,deletedSign);
  723. }
  724. @Override
  725. public List<DemandListBo> areaDemand(int size,String pattern,String showLocation) {
  726. return demandMapper.getAreaDemand(size,pattern,showLocation);
  727. }
  728. @Override
  729. public List<DemandListBo> proLearnStudyDemand(int size,String pattern,String showLocation) {
  730. return demandMapper.getProLearnStudyDemand(size,pattern,showLocation);
  731. }
  732. @Override
  733. public List<DemandListBo> getFundCrowdDemand(int size,String pattern,String showLocation) {
  734. return demandMapper.getFundCrowdDemand(size,pattern,showLocation);
  735. }
  736. @Override
  737. public List<DemandListBo> getPersonnelDemand(int size,String pattern,String showLocation) {
  738. return demandMapper.getPersonnelDemand(size,pattern,showLocation);
  739. }
  740. @SuppressWarnings("unchecked")
  741. @Override
  742. public Pagination<DemandSearchListBo> listAppDemand(Integer auditStatus, Integer serialNumber, String name,
  743. String keyword, Integer demandType,Integer industryCategoryA, String validityPeriodStartDate, String validityPeriodEndDate,
  744. Integer status, Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate,String employerId, Integer pNo,
  745. Integer pSize) {
  746. Map<String, Object> params = disposeParams(auditStatus, null, serialNumber, name, keyword, null, demandType,
  747. validityPeriodStartDate, validityPeriodEndDate, null, status, releaseStatus, releaseDateStartDate,
  748. releaseDateEndDate,null,null, null, null);
  749. if (null!=industryCategoryA) {
  750. params.put("industryCategoryA", industryCategoryA);
  751. }
  752. if (null!=employerId) {
  753. params.put("employerId", employerId);
  754. }
  755. if (pNo == null || pNo < 0) {
  756. pNo = 1;
  757. }
  758. if (pSize == null || pSize < 0) {
  759. pSize = 10;
  760. }
  761. if (null != TokenManager.getUserId()) params.put("uid", TokenManager.getUserId());
  762. Pagination<DemandSearchListBo> p=(Pagination<DemandSearchListBo>) findPage("findAppDemandListByPage", "findAppDemandCount", params, pNo, pSize);
  763. return p;
  764. }
  765. @Override
  766. public DemandListBo getDemandDetail(String id, Integer type) {
  767. return demandMapper.getDemandDetail(id, type);
  768. }
  769. @Override
  770. public int getInterestCount(String id) {
  771. return demandMapper.countInterest(id);
  772. }
  773. @Override
  774. public List<DemandListBo> getBoutiqueDemandList(int i,String pattern,String showLocation) {
  775. return demandMapper.getBoutiqueDemandList(i,pattern,showLocation);
  776. }
  777. @SuppressWarnings("unchecked")
  778. @Override
  779. public Pagination<DemandListBo> listMyDemand(String name, String startDate, String endDate,
  780. Integer pageNo, Integer pageSize) {
  781. Map<String,Object> params = new HashMap<String,Object>();
  782. if(StringUtils.isNotBlank(name)) params.put("name", name);
  783. if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
  784. if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
  785. params.put("employerId", TokenManager.getUserId());
  786. return (Pagination<DemandListBo>) findPage("selectDemandListByPage", "selectDemandListCount", params, pageNo, pageSize);
  787. }
  788. @SuppressWarnings("unchecked")
  789. @Override
  790. public Pagination<DemandListBo> listDemand(String name, String employerName, Integer demandType,
  791. Integer auditStatus, Integer status, String startDate, String endDate,Integer pageNo, Integer pageSize) {
  792. Map<String,Object> params = new HashMap<String,Object>();
  793. if(StringUtils.isNotBlank(name)) params.put("name", name);
  794. if(StringUtils.isNotBlank(employerName)) params.put("identifyName", employerName);
  795. if(demandType != null) params.put("demandType", demandType);
  796. if(auditStatus != null) params.put("auditStatus", auditStatus);
  797. if(status != null) params.put("status",status);
  798. if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
  799. if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
  800. return (Pagination<DemandListBo>) findPage("selectDemandListByPage", "selectDemandListCount", params, pageNo, pageSize);
  801. }
  802. @Override
  803. public DemandDetailBo selectDemandDetail(String id) {
  804. DemandDetailBo bo = demandMapper.selectDemandDetail(id);
  805. bo.setPublishPages(demandPublishMapper.selectPublishPages(id));
  806. return bo;
  807. }
  808. @SuppressWarnings("unchecked")
  809. @Override
  810. public Pagination<DemandListBo> getDemandObjects(DemandListBo demandListBo, Integer pageNo, Integer pageSize) {
  811. if(pageNo==null || pageNo<1) {
  812. pageNo=1;
  813. }
  814. if(pageSize==null ||pageSize<1) {
  815. pageSize=10;
  816. }
  817. return (Pagination<DemandListBo>) findPage("searchDemandList","searchDemandCount",disposeDemandObjectsParams(demandListBo),pageNo , pageSize);
  818. }
  819. private Map<String ,Object>disposeDemandObjectsParams(DemandListBo demandListBo)
  820. {
  821. Map<String, Object>params=new HashMap<>();
  822. if(demandListBo==null)return params;
  823. if(demandListBo.getName() !=null)
  824. {
  825. params.put("name", demandListBo.getName());
  826. }
  827. if(demandListBo.getIndustryCategoryA() !=null)
  828. {
  829. params.put("industryCategoryA", demandListBo.getIndustryCategoryA());
  830. }
  831. if(demandListBo.getIndustryCategoryB() !=null) {
  832. params.put("industryCategoryB", demandListBo.getIndustryCategoryB());
  833. }
  834. if(null != demandListBo.getDeletedSign()){
  835. params.put("deletedSign", demandListBo.getDeletedSign());
  836. }else{
  837. params.put("deletedSign", 0);
  838. }
  839. return params;
  840. }
  841. @SuppressWarnings("unchecked")
  842. @Override
  843. public Pagination<DemandListBo> listInterestedDemand(Integer pageNo, Integer pageSize) {
  844. if(pageNo==null || pageNo<1) {
  845. pageNo=1;
  846. }
  847. if(pageSize==null ||pageSize<1) {
  848. pageSize=10;
  849. }
  850. Map<String, Object> params=new HashMap<String,Object>();
  851. params.put("uid", TokenManager.getUserId());
  852. //params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
  853. return (Pagination<DemandListBo>) findPage("findInterestedDemand", "findInterestedDemandCount", params, pageNo, pageSize);
  854. }
  855. @SuppressWarnings("unchecked")
  856. @Override
  857. public Pagination<MyCollection> myCollectionDemand(Integer pageNo, Integer pageSize) {
  858. if(pageNo==null || pageNo<1) {
  859. pageNo=1;
  860. }
  861. if(pageSize==null ||pageSize<1) {
  862. pageSize=10;
  863. }
  864. Map<String, Object> params=new HashMap<String,Object>();
  865. params.put("uid", TokenManager.getUserId());
  866. // params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
  867. return (Pagination<MyCollection>) findPage("MyCollectionDemandList", "MyCollectionDemandCount", params, pageNo, pageSize);
  868. }
  869. @Override
  870. public int addJtCollectSearch(Demand d) {
  871. int i=0;
  872. if(collectFlag){
  873. JtCollectSearch r=new JtCollectSearch();
  874. r.setFromTable(collectType.DMAND.getDesc());
  875. r.setKeyword(d.getKeyword());
  876. r.setTitle(d.getName());
  877. r.setRowId(d.getId());
  878. String sum = d.getProblemDes();
  879. if(null != sum && sum.length() > 40){
  880. sum = sum.substring(0,40) + "...";
  881. }
  882. r.setSummary(sum);
  883. i=jtCollectSearchMapper.insertSelective(r);
  884. }
  885. return i;
  886. }
  887. @Override
  888. public void batchSaveDemand(MultipartFile file) {
  889. //创建一个对象,用来存储数据
  890. List<Demand> list=new ArrayList<>();
  891. List<DemandKeyword> keyword = new ArrayList<>();
  892. List<DemandPublish> publish = new ArrayList<>();
  893. Sheet sheet=FileUtils.pushReadFile(file);
  894. //获得当前sheet的开始行
  895. int firstRowNum = sheet.getFirstRowNum();
  896. //获得当前sheet最后一行
  897. int lastRowNum=sheet.getLastRowNum();
  898. //循环除了第2行的所有行
  899. Date date=new Date();
  900. //获取技淘网的id
  901. String defaultPlatformId = branchInformationMapper.selectByDomain(PageConstants.DEFAULT_DOMAIN).getId();
  902. for(int rowNum = firstRowNum+2;rowNum <= lastRowNum;rowNum++){
  903. //获得当前行
  904. Row row = sheet.getRow(rowNum);
  905. if(row == null){
  906. continue;
  907. }
  908. //获得当前行的开始列
  909. int firstCellNum = row.getFirstCellNum();
  910. //获得当前行的列数
  911. int lastCellNum = row.getLastCellNum();
  912. //循环当前行 cellNum = (firstCellNum+1) 则是除开第一例
  913. Demand in=new Demand();
  914. List<String> list2 =new ArrayList<>();
  915. for(int cellNum = (firstCellNum); cellNum < lastCellNum;cellNum++){
  916. Cell cell = row.getCell(cellNum);
  917. try {
  918. switch (cellNum) {
  919. case 0:
  920. in.setName(FileUtils.getCellValue(cell));
  921. break;
  922. case 1:
  923. in.setDemandType(Integer.valueOf(FileUtils.getCellValue(cell)));
  924. break;
  925. case 2:
  926. in.setDataCategory(Integer.valueOf(FileUtils.getCellValue(cell)));
  927. break;
  928. case 3:
  929. in.setProblemDes(FileUtils.getCellValue(cell));
  930. if (in.getProblemDes().length()>512) {
  931. list2.add(in.getName());
  932. }
  933. break;
  934. case 4:
  935. in.setKeyword(FileUtils.getCellValue(cell));
  936. break;
  937. case 5:
  938. in.setIsHot(Integer.valueOf(FileUtils.getCellValue(cell)));
  939. break;
  940. case 6:
  941. in.setIsUrgent(Integer.valueOf(FileUtils.getCellValue(cell)));
  942. break;
  943. case 7:
  944. in.setUrgentDays(Integer.valueOf(FileUtils.getCellValue(cell)));
  945. break;
  946. case 8:
  947. in.setUrgentMoney(new BigDecimal(FileUtils.getCellValue(cell)));
  948. break;
  949. }
  950. } catch (Exception e) {
  951. throw new BusinessException(new Error("表格第"+(rowNum+1)+"行输入内容不正确。"));
  952. }
  953. }
  954. if (!list2.isEmpty()) {
  955. StringBuffer str=new StringBuffer("[");
  956. for (String string : list2) {
  957. str.append(string+",");
  958. }
  959. str.deleteCharAt(str.length()-1);
  960. str.append("]");
  961. throw new BusinessException(new Error("名称"+str+"内容过长,请控制在512个字符内"));
  962. }
  963. in.setDeletedSign(DeleteStatus.UNDELETE.getCode());
  964. in.setEmployerId(TokenManager.getAdminId());
  965. in.setCreateTime(date);
  966. in.setStatus(0);
  967. in.setReleaseStatus(AchievementAuditStatus.CREATE.getCode());
  968. in.setAuditStatus(0);
  969. in.setId(UUID.randomUUID().toString());
  970. in.setInfoSources(1);
  971. list.add(in);
  972. //关键字处理
  973. if(in.getKeyword()!=null) {
  974. String [] keywords=null;
  975. boolean flag= false;
  976. if (in.getKeyword().contains(",")) {
  977. keywords=in.getKeyword().split(",");
  978. flag=true;
  979. }else if (in.getKeyword().contains(",")) {
  980. keywords=in.getKeyword().split(",");
  981. flag=true;
  982. }else {
  983. DemandKeyword ak = new DemandKeyword();
  984. ak.setId(UUID.randomUUID().toString());
  985. ak.setDemandId(in.getId());
  986. ak.setKeyword(in.getKeyword());
  987. keyword.add(ak);
  988. }
  989. if (flag) {
  990. for (String string : keywords) {
  991. DemandKeyword ak = new DemandKeyword();
  992. ak.setId(UUID.randomUUID().toString());
  993. ak.setDemandId(in.getId());
  994. ak.setKeyword(string);
  995. keyword.add(ak);
  996. }
  997. }
  998. }
  999. DemandPublish ap = new DemandPublish();
  1000. ap.setId(UUID.randomUUID().toString());
  1001. ap.setDemandId((in.getId()));
  1002. ap.setPublisher(TokenManager.getUserId());
  1003. ap.setPublishTime(date);
  1004. ap.setPublishClient(PageConstants.WEB_PLATFORM);
  1005. ap.setPublishPage("wep_demand_list");
  1006. ap.setPublishPlatform(defaultPlatformId);
  1007. ap.setIfTop(AFTConstants.NO);
  1008. ap.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
  1009. ap.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
  1010. publish.add(ap);
  1011. DemandPublish ap2 = new DemandPublish();
  1012. ap2.setId(UUID.randomUUID().toString());
  1013. ap2.setDemandId(in.getId());
  1014. ap2.setPublisher(TokenManager.getUserId());
  1015. ap2.setPublishTime(date);
  1016. ap2.setPublishClient(PageConstants.APP_PLATFORM);
  1017. ap2.setPublishPage("app_demand_list");
  1018. ap2.setPublishPlatform(defaultPlatformId);
  1019. ap2.setIfTop(AFTConstants.NO);
  1020. ap2.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
  1021. ap2.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
  1022. publish.add(ap2);
  1023. }
  1024. demandMapper.insertBatch(list);
  1025. demandKeywordMapper.insertBatch(keyword);
  1026. demandPublishMapper.insertBatch(publish);
  1027. }
  1028. }