| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121 |
- package com.goafanti.demand.service.impl;
- import java.math.BigDecimal;
- import java.text.ParseException;
- import java.util.ArrayList;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.poi.ss.usermodel.Cell;
- import org.apache.poi.ss.usermodel.Row;
- import org.apache.poi.ss.usermodel.Sheet;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.web.multipart.MultipartFile;
- import com.goafanti.common.bo.Error;
- import com.goafanti.common.bo.MyCollection;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.constant.PageConstants;
- import com.goafanti.common.dao.AchievementDemandCountMapper;
- import com.goafanti.common.dao.AchievementDemandMapper;
- import com.goafanti.common.dao.AchievementKeywordMapper;
- import com.goafanti.common.dao.AchievementMapper;
- import com.goafanti.common.dao.BranchInformationMapper;
- import com.goafanti.common.dao.DemandFollowDetailMapper;
- import com.goafanti.common.dao.DemandInterestMapper;
- import com.goafanti.common.dao.DemandKeywordMapper;
- import com.goafanti.common.dao.DemandMapper;
- import com.goafanti.common.dao.DemandPublishMapper;
- import com.goafanti.common.dao.FieldGlossoryMapper;
- import com.goafanti.common.dao.JtCollectSearchMapper;
- import com.goafanti.common.dao.NewsInterestMapper;
- import com.goafanti.common.dao.NoticeMapper;
- import com.goafanti.common.dao.OrganizationIdentityMapper;
- import com.goafanti.common.dao.ProjectInterestMapper;
- import com.goafanti.common.dao.UserIdentityMapper;
- import com.goafanti.common.dao.UserInterestMapper;
- import com.goafanti.common.dao.UserMapper;
- import com.goafanti.common.dao.UserRoleMapper;
- import com.goafanti.common.enums.AchievementAuditStatus;
- import com.goafanti.common.enums.DeleteStatus;
- import com.goafanti.common.enums.DemandAuditStatus;
- import com.goafanti.common.enums.DemandInfoSourceStatus;
- import com.goafanti.common.enums.DemandReleaseStatus;
- import com.goafanti.common.enums.DemandStatus;
- import com.goafanti.common.enums.InterestType;
- import com.goafanti.common.enums.NoticeReadStatus;
- import com.goafanti.common.enums.NoticeStatus;
- import com.goafanti.common.enums.UserType;
- import com.goafanti.common.enums.collectType;
- import com.goafanti.common.error.BusinessException;
- import com.goafanti.common.model.AchievementDemand;
- import com.goafanti.common.model.AchievementDemandCount;
- import com.goafanti.common.model.Demand;
- import com.goafanti.common.model.DemandKeyword;
- import com.goafanti.common.model.DemandPublish;
- import com.goafanti.common.model.JtCollectSearch;
- import com.goafanti.common.model.Notice;
- import com.goafanti.common.model.OrganizationIdentity;
- import com.goafanti.common.model.User;
- import com.goafanti.common.model.UserIdentity;
- import com.goafanti.common.utils.DateUtils;
- import com.goafanti.common.utils.FileUtils;
- import com.goafanti.core.mybatis.BaseMybatisDao;
- import com.goafanti.core.mybatis.page.Pagination;
- import com.goafanti.core.shiro.token.TokenManager;
- import com.goafanti.demand.bo.AppDemandBo;
- import com.goafanti.demand.bo.DemandDetailBo;
- import com.goafanti.demand.bo.DemandImportBo;
- import com.goafanti.demand.bo.DemandListBo;
- import com.goafanti.demand.bo.ObjectInterestListBo;
- import com.goafanti.demand.service.DemandService;
- import com.goafanti.portal.bo.DemandSearchDetailBo;
- import com.goafanti.portal.bo.DemandSearchListBo;
- @Service
- public class DemandServiceImpl extends BaseMybatisDao<DemandMapper> implements DemandService {
- @Autowired
- private DemandMapper demandMapper;
- @Autowired
- private UserMapper userMapper;
- @Autowired
- private UserRoleMapper userRoleMapper;
- @Autowired
- private NoticeMapper noticeMapper;
- @Autowired
- private DemandKeywordMapper demandKeywordMapper;
- @Autowired
- private AchievementDemandMapper achievementDemandMapper;
- @Autowired
- private AchievementKeywordMapper achievementKeywordMapper;
- @Autowired
- private AchievementDemandCountMapper achievementDemandCountMapper;
- @Autowired
- private UserIdentityMapper userIdentityMapper;
- @Autowired
- private OrganizationIdentityMapper organizationIdentityMapper;
- @Autowired
- private AchievementMapper achievementMapper;
- @Autowired
- private DemandInterestMapper demandInterestMapper;
- @Autowired
- private NewsInterestMapper newsInterestMapper;
- @Autowired
- private UserInterestMapper userInterestMapper;
- @Autowired
- ProjectInterestMapper projectInterestMapper;
- @Autowired
- DemandFollowDetailMapper demandFollowDetailMapper;
- @Autowired
- FieldGlossoryMapper fieldGlossoryMapper;
- @Autowired
- BranchInformationMapper branchInformationMapper;
- @Autowired
- DemandPublishMapper demandPublishMapper;
- @Autowired
- JtCollectSearchMapper jtCollectSearchMapper;
-
- @Value(value="${collect_flag}")
- private Boolean collectFlag ;
- @Override
- public int updateUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords,List<String> webPages,List<String> appPages) {
- Date validityPeriod = null;
- if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
- try {
- validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- d.setValidityPeriod(validityPeriod);
- disposeDemandKeyword(keywords, d, true);
- disposeDemandPublish(d,webPages,appPages,true);
- demandMapper.updateByPrimaryKeySelective(d);
- return 1;
- }
- @Override
- public DemandDetailBo selectUserDemandDetail(String id) {
- return demandMapper.selectUserDemandDetail(id);
- }
- @Override
- public int deleteByPrimaryKey(List<String> id) {
- demandKeywordMapper.batchDeleteByDemandIds(id);
- achievementDemandMapper.batchDeleteByDemandIds(id);
- demandPublishMapper.batchDeleteByDemandIds(id);
-
- for (String s : id) {
- Demand d = demandMapper.selectByPrimaryKey(s);
- if(collectFlag)jtCollectSearchMapper.deleteByrowId(s);
- if (null != d && DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
- && StringUtils.isNotBlank(d.getEmployerId())) {
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(d.getEmployerId());
- if (null != adc) {
- adc.setDemandCount(adc.getDemandCount() - 1);
- if (adc.getDemandCount() < 0) {
- adc.setDemandCount(0);
- }
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- }
- return demandMapper.batchDeleteByPrimaryKey(id);
- }
- @Override
- public DemandDetailBo selectOrgDemandDetail(String id) {
-
- return demandMapper.selectOrgDemandDetail(id);
- }
- @Override
- public Demand selectByPrimaryKey(String id) {
- return demandMapper.selectByPrimaryKey(id);
- }
-
- @Override
- public int updateReleaseStatus(Demand d) {
- d.setAuditStatus(DemandAuditStatus.AUDITED.getCode());
- if(d.getReleaseStatus()==1){
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- d.setReleaseDate(now.getTime());
- }
- d.setStatus(DemandStatus.UNRESOLVED.getCode());
- d.setAuditStatus(DemandAuditStatus.REVOKE.getCode());
- int i=0;
- i=demandMapper.updateByPrimaryKeySelective(d);
- if(collectFlag)jtCollectSearchMapper.deleteByrowId(d.getId());
- demandKeywordMapper.batchDeleteByDemandId(d.getId());
- achievementDemandMapper.deleteByDemandId(d.getId());
- if (StringUtils.isNotBlank(d.getEmployerId())) {
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(d.getEmployerId());
- if (null != adc) {
- adc.setDemandCount(adc.getDemandCount() - 1);
- if (adc.getDemandCount() < 0) {
- adc.setDemandCount(0);
- }
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- disposeDemandPublish(d, null, null, true);
- return i;
- }
- @Override
- public int updateAuditDemand(Demand d, String techBroderId, Integer auditStatus) {
- d.setAuditStatus(auditStatus);
- if (DemandAuditStatus.AUDITED.getCode().equals(auditStatus)) {
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- d.setReleaseDate(now.getTime());
- d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- d.setTechBrokerId(techBroderId);
- if (StringUtils.isNotBlank(d.getKeyword())) {
- String[] keywords = d.getKeyword().trim().split(",|,");
- disposeDemandKeyword(keywords, d, false);
- }
- String employerId = d.getEmployerId();
- if (StringUtils.isNotBlank(employerId)) {
- if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
- UserIdentity ui = userIdentityMapper.selectUserIdentityByUserId(employerId);
- if (null != ui) {
- d.setEmployerName(ui.getUsername());
- }
- } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
- OrganizationIdentity oi = organizationIdentityMapper.selectOrgIdentityByUserId(employerId);
- if (null != oi) {
- d.setEmployerName(oi.getUnitName());
- }
- }
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(employerId);
- if (null == adc) {
- AchievementDemandCount achievementDemandCount = new AchievementDemandCount();
- achievementDemandCount.setId(UUID.randomUUID().toString());
- achievementDemandCount.setUid(employerId);
- achievementDemandCount.setDemandCount(AFTConstants.ACHIEVEMENT_DEMAND_FIRST_COUNT);
- achievementDemandCount.setAchievementCount(AFTConstants.ACHIEVEMENT_DEMAND_INIT_COUNT);
- achievementDemandCountMapper.insert(achievementDemandCount);
- } else {
- adc.setDemandCount(adc.getDemandCount() + 1);
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- } else {
- d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- }
- createTechBorkerNotice(d);
- return demandMapper.updateByPrimaryKeySelective(d);
- }
- @Override
- public void saveDemand(Demand d, String validityPeriodFormattedDate, String[] keywords,List<String> webPages, List<String> appPages) {
- Date validityPeriod = null;
- if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
- try {
- validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- d.setValidityPeriod(validityPeriod);
- d.setId(UUID.randomUUID().toString());
- d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- // d.setStatus(DemandStatus.UNRESOLVED.getCode());
- d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- d.setInfoSources(1);
- if (DemandAuditStatus.INAUDIT.getCode().equals(d.getAuditStatus())) {
- createAuditorNotice(d);
- // d.setReleaseDate(new Date());
- } else {
- d.setAuditStatus(DemandAuditStatus.CREATE.getCode());
- }
- d.setCreateTime(now.getTime());
- demandMapper.insert(d);
- disposeDemandKeyword(keywords, d, false);
- disposeDemandPublish(d,webPages,appPages,false);
- }
- @Override
- public void insertImport(List<DemandImportBo> data) {
- if (null == data || data.isEmpty()) {
- return;
- }
- Demand d = null;
- DemandKeyword dk = null;
- List<Demand> demandList = new ArrayList<>();
- List<DemandKeyword> demandKeywordList = new ArrayList<>();
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- String techBrokerId = TokenManager.getAdminId();
- for (DemandImportBo bo : data) {
- d = new Demand();
- BeanUtils.copyProperties(bo, d);
- d.setId(UUID.randomUUID().toString());
- d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- d.setCreateTime(now.getTime());
- d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
- d.setStatus(DemandStatus.UNRESOLVED.getCode());
- d.setInfoSources(DemandInfoSourceStatus.IMPORT.getCode());
- d.setTechBrokerId(techBrokerId);
- List<String> keywordsList = bo.getKeywords();
- if (null != keywordsList && keywordsList.size() > 0) {
- for (String s : keywordsList) {
- if (!StringUtils.isBlank(s)) {
- dk = new DemandKeyword();
- dk.setDemandId(d.getId());
- dk.setKeyword(s.trim());
- dk.setId(UUID.randomUUID().toString());
- demandKeywordList.add(dk);
- }
- }
- }
- demandList.add(d);
- }
- demandMapper.insertBatch(demandList);
- demandKeywordMapper.insertBatch(demandKeywordList);
- }
- @Override
- public DemandSearchDetailBo selectDemandDetail(String uid, String id) {
- return demandMapper.selectDemandDetail(uid, id);
- }
- private Map<String, Object> disposeParams(Integer auditStatus, Integer province, Integer serialNumber, String name,
- String keyword, Integer infoSources, Integer demandType, String validityPeriodStartDate,
- String validityPeriodEndDate, String username, Integer status, Integer releaseStatus,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer boutique, Integer hot) {
- Map<String, Object> params = new HashMap<>();
- Date vStart = null;
- Date vEnd = null;
- Date rStart = null;
- Date rEnd = null;
- Date cStart = null;
- Date cEnd = null;
- if (!StringUtils.isBlank(validityPeriodStartDate)) {
- try {
- vStart = DateUtils.parseDate(validityPeriodStartDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- if (!StringUtils.isBlank(validityPeriodEndDate)) {
- try {
- vEnd = DateUtils.addDays(DateUtils.parseDate(validityPeriodEndDate, AFTConstants.YYYYMMDD), 1);
- } catch (ParseException e) {
- }
- }
- if (!StringUtils.isBlank(releaseDateStartDate)) {
- try {
- rStart = DateUtils.parseDate(releaseDateStartDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- if (!StringUtils.isBlank(releaseDateEndDate)) {
- try {
- rEnd = DateUtils.addDays(DateUtils.parseDate(releaseDateEndDate, AFTConstants.YYYYMMDD), 1);
- } catch (ParseException e) {
- }
- }
- if (!StringUtils.isBlank(createDateStartDate)) {
- try {
- cStart = DateUtils.parseDate(createDateStartDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- if (!StringUtils.isBlank(createDateEndDate)) {
- try {
- cEnd = DateUtils.addDays(DateUtils.parseDate(createDateEndDate, AFTConstants.YYYYMMDD), 1);
- } catch (ParseException e) {
- }
- }
- if (null != vStart) {
- params.put("vStart", vStart);
- }
- if (null != vEnd) {
- params.put("vEnd", vEnd);
- }
- if (null != rStart) {
- params.put("rStart", rStart);
- }
- if (null != rEnd) {
- params.put("rEnd", rEnd);
- }
- if (null != cStart) {
- params.put("cStart", cStart);
- }
- if (null != cEnd) {
- params.put("cEnd", cEnd);
- }
- if (null != auditStatus) {
- params.put("auditStatus", auditStatus);
- }
- if (null != province) {
- params.put("province", province);
- }
- if (null != serialNumber) {
- params.put("serialNumber", serialNumber);
- }
- if (!StringUtils.isBlank(name)) {
- params.put("name", name);
- }
- if (!StringUtils.isBlank(keyword)) {
- params.put("keyword", keyword);
- }
- /*
- * if (!StringUtils.isBlank(username)) { params.put("username",
- * username); }
- */
- if (null != infoSources) {
- params.put("infoSources", infoSources);
- }
- if (null != demandType) {
- params.put("demandType", demandType);
- }
- if (null != status) {
- params.put("status", status);
- }
- if (null != releaseStatus) {
- params.put("releaseStatus", releaseStatus);
- }
- if (null != boutique) {
- params.put("boutique", boutique);
- }
- if (null != hot) {
- params.put("hot", hot);
- }
- return params;
- }
- // 给所有审核员发送审核通知
- private void createAuditorNotice(Demand d) {
- List<String> ids = userRoleMapper.listAuditor();
- List<Notice> list = new ArrayList<>();
- if (null != ids && ids.size() > 0) {
- for (String s : ids) {
- list.add(disposeNotice(d, s));
- }
- noticeMapper.insertBatch(list);
- }
- }
- // 给指派技术经纪人发送审核结果通知
- private void createTechBorkerNotice(Demand a) {
- // noticeMapper.insert(disposeNotice(a, null));
- }
- private Notice disposeNotice(Demand d, String aid) {
- Notice n = new Notice();
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- n.setId(UUID.randomUUID().toString());
- n.setCreateTime(now.getTime());
- n.setReaded(NoticeReadStatus.UNREAD.getCode());
- n.setRid(d.getId());
- User u = userMapper.selectByPrimaryKey(d.getEmployerId());
- if (null != u) {
- n.setPid(u.getAid());
- }
- if (StringUtils.isBlank(aid)) {
- n.setAid(d.getTechBrokerId());
- if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
- n.setContent("编号" + d.getSerialNumber() + NoticeStatus.PERSONALDEMAND.getDesc() + " "
- + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
- ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
- n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
- } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
- n.setContent("编号" + d.getSerialNumber() + NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " "
- + (DemandAuditStatus.AUDITED.getCode().equals(d.getAuditStatus())
- ? DemandAuditStatus.AUDITED.getDesc() : DemandAuditStatus.UNAUDITED.getDesc()));
- n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
- }
- } else {
- n.setAid(aid);
- if (UserType.PERSONAL.getCode().equals(d.getDataCategory())) {
- n.setContent(NoticeStatus.PERSONALDEMAND.getDesc() + " " + DemandAuditStatus.INAUDIT.getDesc());
- n.setNoticeType(NoticeStatus.PERSONALDEMAND.getCode());
- } else if (UserType.ORGANIZATION.getCode().equals(d.getDataCategory())) {
- n.setContent(NoticeStatus.ORGANIZATIONDEMAND.getDesc() + " " + DemandAuditStatus.INAUDIT.getDesc());
- n.setNoticeType(NoticeStatus.ORGANIZATIONDEMAND.getCode());
- }
- }
- return n;
- }
- private void disposeDemandPublish(Demand d,List<String> webPages,List<String> appPages,boolean delete){
- if(delete){
- if(null != webPages && webPages.size()>0){
- demandPublishMapper.deleteByDemandId(d.getId());
- }
- }
- DemandPublish dp = null;
- String defaultPlatformId = branchInformationMapper.selectByDomain(PageConstants.DEFAULT_DOMAIN).getId();
- if(webPages != null && webPages.size()>0){
- for(String page: webPages){
- dp = new DemandPublish();
- dp.setId(UUID.randomUUID().toString());
- dp.setDemandId(d.getId());
- dp.setPublisher(TokenManager.getUserId());
- // dp.setPublisher("1");
- dp.setPublishTime(d.getReleaseDate()==null?new Date():d.getReleaseDate());
- dp.setPublishClient(PageConstants.WEB_PLATFORM);
- dp.setPublishPage(page);
- dp.setPublishPlatform(defaultPlatformId);
- dp.setIfTop(AFTConstants.NO);
- dp.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
- dp.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
- demandPublishMapper.insert(dp);
- }
- }
- if(appPages != null && appPages.size()>0){
- for(String page: appPages){
- dp = new DemandPublish();
- dp.setId(UUID.randomUUID().toString());
- dp.setDemandId(d.getId());
- dp.setPublisher(TokenManager.getUserId());
- // dp.setPublisher("1");
- dp.setPublishTime(d.getReleaseDate()==null?new Date():d.getReleaseDate());
- dp.setPublishClient(PageConstants.APP_PLATFORM);
- dp.setPublishPage(page);
- dp.setPublishPlatform(defaultPlatformId);
- dp.setIfTop(AFTConstants.NO);
- dp.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
- dp.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
- demandPublishMapper.insert(dp);
- }
- }
- }
-
- private void disposeDemandKeyword(String[] keywords, Demand d, boolean delete) {
- if (null != keywords && keywords.length > 0) {
- if (delete) {
- demandKeywordMapper.batchDeleteByDemandId(d.getId());
- }
- List<DemandKeyword> list = new ArrayList<>();
- DemandKeyword dk = null;
- for (int i = 0; i < keywords.length; i++) {
- dk = new DemandKeyword();
- dk.setId(UUID.randomUUID().toString());
- dk.setDemandId(d.getId());
- dk.setKeyword(keywords[i].trim());
- list.add(dk);
- }
- demandKeywordMapper.insertBatch(list);
- }
- }
- @Override
- public int updateMatchAchievement(Demand d) {
- achievementDemandMapper.deleteByDemandId(d.getId());
- List<DemandKeyword> demand = demandKeywordMapper.selectKeywordsByDemandId(d.getId());
- if (null != demand && demand.size() > 0) {
- List<String> keyword = new ArrayList<>();
- for (DemandKeyword k : demand) {
- if (!StringUtils.isBlank(k.getKeyword())) {
- keyword.add(k.getKeyword());
- }
- }
- List<AchievementDemand> list = achievementKeywordMapper.selectAchievementDemand(keyword);
- if (null != list && list.size() > 0) {
- for (AchievementDemand ad : list) {
- ad.setDemandId(d.getId());
- }
- return achievementDemandMapper.insertBatch(list);
- }
- }
- return 0;
- }
- @Override
- public int updateByPrimaryKeySelective(Demand d) {
- int i=demandMapper.updateByPrimaryKeySelective(d);
- if(collectFlag && null != d.getStatus()){
- if (d.getAuditStatus()==2) {
- JtCollectSearch r=new JtCollectSearch();
- r.setFromTable(collectType.DMAND.getDesc());
- r.setKeyword(d.getKeyword());
- r.setTitle(d.getName());
- r.setRowId(d.getId());
- String sum = d.getProblemDes();
- if(null != sum && sum.length() > 40){
- sum = sum.substring(0,40) + "...";
- }
- r.setSummary(sum);
- jtCollectSearchMapper.insertSelective(r);
- }
- if (d.getAuditStatus()==4||d.getAuditStatus()==3) {
- if(collectFlag)jtCollectSearchMapper.deleteByrowId(d.getId());
- }
- }
- return i;
- }
-
- @Override
- public AppDemandBo selectAppDemandDetail(String id ) {
- String uid=TokenManager.getUserId();
- //uid="0261d476-8336-4a0b-97d7-83c89e286852";
- return demandMapper.selectAppByPrimaryKey(id,uid);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<ObjectInterestListBo> selectinterest(Integer type,Integer pNo, Integer pSize) {
- Map<String, Object> params=new HashMap<>();
- params.put("type", type);
- if (StringUtils.isNotBlank(TokenManager.getUserId())) {
- params.put("uid", TokenManager.getUserId());
- }
- //params.put("uid", "6d71349c-7bb8-4e8a-8c03-0c3f36fc66ae");
- if (type==InterestType.POLICY.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppNewsInterestByPage", "findAppNewsInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=newsInterestMapper.countInterest(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- if (type==InterestType.EXPERTS.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppUserInterestByPage", "findAppUserInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=userInterestMapper.countInterest(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- if (type==InterestType.DEMAND.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppDemandInterestByPage", "findAppDemandInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=demandInterestMapper.checkCount(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- if (null==type||type==InterestType.ACHIEVEMENT.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppAchievementInterestByPage", "findAppAchievementInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=achievementMapper.countInterest(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- if (null==type||type==InterestType.PROJECT.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppProjectInterestByPage", "findAppProjectInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=projectInterestMapper.countInterest(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- if (type==InterestType.COUNSELOR.getCode()) {
- Pagination<ObjectInterestListBo> p=(Pagination<ObjectInterestListBo>) findPage("findAppCounselorInterestByPage", "findAppCounselorInterestCount", params, pNo, pSize);
- List<ObjectInterestListBo> l=(List<ObjectInterestListBo>) p.getList();
- for (ObjectInterestListBo o : l) {
- int i=userInterestMapper.countInterest(o.getId());
- o.setCountInterest(String.valueOf(i));
- o.setType(type);
- }
- return p;
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AppDemandBo> listMyDemand(Integer pNo, Integer pSize) {
- Map<String, Object> params = new HashMap<>();
- if (pNo == null || pNo < 0) pNo = 1;
- if (pSize == null || pSize < 0) pSize = 10;
- if (StringUtils.isNotBlank(TokenManager.getUserId())) params.put("employerId", TokenManager.getUserId());
- //params.put("employerId", "46433140-0a90-471e-a32f-6bc89c562e3d");
- return (Pagination<AppDemandBo>) findPage("findAppMyDemandListByPage", "findAppMyDemandCount", params, pNo, pSize);
- }
- public int saveAppUserDemand(Demand d, String validityPeriodFormattedDate, String[] keywords) {
- Date validityPeriod = null;
- if (!StringUtils.isBlank(validityPeriodFormattedDate)) {
- try {
- validityPeriod = DateUtils.parseDate(validityPeriodFormattedDate, AFTConstants.YYYYMMDD);
- } catch (ParseException e) {
- }
- }
- d.setInfoSources(1);
- if (null!=TokenManager.getUserId()) {
- d.setEmployerId(TokenManager.getUserId());
- User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
- if (null!=u.getType()) {
- d.setDataCategory(u.getType());
- }
- if (StringUtils.isNotBlank(u.getId())) {
- d.setEmployerId(u.getId());
- }
-
- if (StringUtils.isNotBlank(u.getMobile())) {
- d.setEmployerContactsMobile(u.getMobile());
- }
- }
- d.setValidityPeriod(validityPeriod);
-
- d.setId(UUID.randomUUID().toString());
- d.setTechBrokerId(TokenManager.getAdminId());
- d.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- d.setStatus(DemandStatus.UNRESOLVED.getCode());
- d.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- d.setPrincipalId(TokenManager.getAdminId());
- d.setAuditStatus(DemandAuditStatus.INAUDIT.getCode());
- createAuditorNotice(d);
- if (null==d.getKeyword()) {
- d.setKeyword("");
- }
- d.setCreateTime(now.getTime());
- disposeDemandKeyword(keywords, d, false);
- return demandMapper.insert(d);
- }
- @Override
- public Demand DemandFollowDetails(String id) {
- return demandMapper.selectDemandFollow(id);
- }
-
- @Override
- public List<DemandListBo> recentDemand(int size,String pattern,String showLocation) {
- return demandMapper.selectRecentDemand(size,pattern,showLocation);
- }
-
- @Override
- public List<DemandListBo> companyDemand(int size,String pattern,String showLocation) {
- return demandMapper.selectCompanyDemand(size,pattern,showLocation);
- }
- @Override
- public List<DemandListBo> getUrgentDemand(int size,String pattern,String showLocation) {
- return demandMapper.getUrgentDemand(size,pattern,showLocation);
- }
- @Override
- public List<DemandListBo> getHotDemand(int size,String pattern,String showLocation, int deletedSign) {
- return demandMapper.getHotDemand(size,pattern,showLocation,deletedSign);
- }
- @Override
- public List<DemandListBo> areaDemand(int size,String pattern,String showLocation) {
- return demandMapper.getAreaDemand(size,pattern,showLocation);
- }
- @Override
- public List<DemandListBo> proLearnStudyDemand(int size,String pattern,String showLocation) {
- return demandMapper.getProLearnStudyDemand(size,pattern,showLocation);
- }
- @Override
- public List<DemandListBo> getFundCrowdDemand(int size,String pattern,String showLocation) {
- return demandMapper.getFundCrowdDemand(size,pattern,showLocation);
- }
- @Override
- public List<DemandListBo> getPersonnelDemand(int size,String pattern,String showLocation) {
- return demandMapper.getPersonnelDemand(size,pattern,showLocation);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<DemandSearchListBo> listAppDemand(Integer auditStatus, Integer serialNumber, String name,
- String keyword, Integer demandType,Integer industryCategoryA, String validityPeriodStartDate, String validityPeriodEndDate,
- Integer status, Integer releaseStatus, String releaseDateStartDate, String releaseDateEndDate,String employerId, Integer pNo,
- Integer pSize) {
- Map<String, Object> params = disposeParams(auditStatus, null, serialNumber, name, keyword, null, demandType,
- validityPeriodStartDate, validityPeriodEndDate, null, status, releaseStatus, releaseDateStartDate,
- releaseDateEndDate,null,null, null, null);
- if (null!=industryCategoryA) {
- params.put("industryCategoryA", industryCategoryA);
- }
- if (null!=employerId) {
- params.put("employerId", employerId);
- }
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0) {
- pSize = 10;
-
- }
- if (null != TokenManager.getUserId()) params.put("uid", TokenManager.getUserId());
- Pagination<DemandSearchListBo> p=(Pagination<DemandSearchListBo>) findPage("findAppDemandListByPage", "findAppDemandCount", params, pNo, pSize);
- return p;
- }
- @Override
- public DemandListBo getDemandDetail(String id, Integer type) {
- return demandMapper.getDemandDetail(id, type);
- }
- @Override
- public int getInterestCount(String id) {
- return demandMapper.countInterest(id);
- }
- @Override
- public List<DemandListBo> getBoutiqueDemandList(int i,String pattern,String showLocation) {
- return demandMapper.getBoutiqueDemandList(i,pattern,showLocation);
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<DemandListBo> listMyDemand(String name, String startDate, String endDate,
- Integer pageNo, Integer pageSize) {
- Map<String,Object> params = new HashMap<String,Object>();
- if(StringUtils.isNotBlank(name)) params.put("name", name);
- if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
- if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
- params.put("employerId", TokenManager.getUserId());
- return (Pagination<DemandListBo>) findPage("selectDemandListByPage", "selectDemandListCount", params, pageNo, pageSize);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<DemandListBo> listDemand(String name, String employerName, Integer demandType,
- Integer auditStatus, Integer status, String startDate, String endDate,Integer pageNo, Integer pageSize) {
- Map<String,Object> params = new HashMap<String,Object>();
- if(StringUtils.isNotBlank(name)) params.put("name", name);
- if(StringUtils.isNotBlank(employerName)) params.put("identifyName", employerName);
- if(demandType != null) params.put("demandType", demandType);
- if(auditStatus != null) params.put("auditStatus", auditStatus);
- if(status != null) params.put("status",status);
- if(StringUtils.isNotBlank(startDate)) params.put("startDate", startDate);
- if(StringUtils.isNotBlank(endDate)) params.put("endDate", endDate);
- return (Pagination<DemandListBo>) findPage("selectDemandListByPage", "selectDemandListCount", params, pageNo, pageSize);
- }
-
- @Override
- public DemandDetailBo selectDemandDetail(String id) {
- DemandDetailBo bo = demandMapper.selectDemandDetail(id);
- bo.setPublishPages(demandPublishMapper.selectPublishPages(id));
- return bo;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<DemandListBo> getDemandObjects(DemandListBo demandListBo, Integer pageNo, Integer pageSize) {
- if(pageNo==null || pageNo<1) {
- pageNo=1;
- }
- if(pageSize==null ||pageSize<1) {
- pageSize=10;
- }
- return (Pagination<DemandListBo>) findPage("searchDemandList","searchDemandCount",disposeDemandObjectsParams(demandListBo),pageNo , pageSize);
- }
-
- private Map<String ,Object>disposeDemandObjectsParams(DemandListBo demandListBo)
- {
- Map<String, Object>params=new HashMap<>();
- if(demandListBo==null)return params;
- if(demandListBo.getName() !=null)
- {
- params.put("name", demandListBo.getName());
- }
- if(demandListBo.getIndustryCategoryA() !=null)
- {
- params.put("industryCategoryA", demandListBo.getIndustryCategoryA());
- }
- if(demandListBo.getIndustryCategoryB() !=null) {
- params.put("industryCategoryB", demandListBo.getIndustryCategoryB());
- }
- if(null != demandListBo.getDeletedSign()){
- params.put("deletedSign", demandListBo.getDeletedSign());
- }else{
- params.put("deletedSign", 0);
- }
- return params;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<DemandListBo> listInterestedDemand(Integer pageNo, Integer pageSize) {
- if(pageNo==null || pageNo<1) {
- pageNo=1;
- }
- if(pageSize==null ||pageSize<1) {
- pageSize=10;
- }
- Map<String, Object> params=new HashMap<String,Object>();
- params.put("uid", TokenManager.getUserId());
- //params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
- return (Pagination<DemandListBo>) findPage("findInterestedDemand", "findInterestedDemandCount", params, pageNo, pageSize);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<MyCollection> myCollectionDemand(Integer pageNo, Integer pageSize) {
- if(pageNo==null || pageNo<1) {
- pageNo=1;
- }
- if(pageSize==null ||pageSize<1) {
- pageSize=10;
- }
- Map<String, Object> params=new HashMap<String,Object>();
- params.put("uid", TokenManager.getUserId());
- // params.put("uid", "1180fa62-7c42-44be-bc41-5583814d69f4");
- return (Pagination<MyCollection>) findPage("MyCollectionDemandList", "MyCollectionDemandCount", params, pageNo, pageSize);
- }
- @Override
- public int addJtCollectSearch(Demand d) {
- int i=0;
- if(collectFlag){
- JtCollectSearch r=new JtCollectSearch();
- r.setFromTable(collectType.DMAND.getDesc());
- r.setKeyword(d.getKeyword());
- r.setTitle(d.getName());
- r.setRowId(d.getId());
- String sum = d.getProblemDes();
- if(null != sum && sum.length() > 40){
- sum = sum.substring(0,40) + "...";
- }
- r.setSummary(sum);
- i=jtCollectSearchMapper.insertSelective(r);
- }
- return i;
- }
- @Override
- public void batchSaveDemand(MultipartFile file) {
- //创建一个对象,用来存储数据
- List<Demand> list=new ArrayList<>();
- List<DemandKeyword> keyword = new ArrayList<>();
- List<DemandPublish> publish = new ArrayList<>();
- Sheet sheet=FileUtils.pushReadFile(file);
- //获得当前sheet的开始行
- int firstRowNum = sheet.getFirstRowNum();
- //获得当前sheet最后一行
- int lastRowNum=sheet.getLastRowNum();
- //循环除了第2行的所有行
- Date date=new Date();
- //获取技淘网的id
- String defaultPlatformId = branchInformationMapper.selectByDomain(PageConstants.DEFAULT_DOMAIN).getId();
- for(int rowNum = firstRowNum+2;rowNum <= lastRowNum;rowNum++){
- //获得当前行
- Row row = sheet.getRow(rowNum);
- if(row == null){
- continue;
- }
- //获得当前行的开始列
- int firstCellNum = row.getFirstCellNum();
- //获得当前行的列数
- int lastCellNum = row.getLastCellNum();
- //循环当前行 cellNum = (firstCellNum+1) 则是除开第一例
- Demand in=new Demand();
- List<String> list2 =new ArrayList<>();
- for(int cellNum = (firstCellNum); cellNum < lastCellNum;cellNum++){
- Cell cell = row.getCell(cellNum);
- try {
- switch (cellNum) {
- case 0:
- in.setName(FileUtils.getCellValue(cell));
- break;
- case 1:
- in.setDemandType(Integer.valueOf(FileUtils.getCellValue(cell)));
- break;
- case 2:
- in.setDataCategory(Integer.valueOf(FileUtils.getCellValue(cell)));
- break;
- case 3:
- in.setProblemDes(FileUtils.getCellValue(cell));
- if (in.getProblemDes().length()>512) {
- list2.add(in.getName());
- }
- break;
- case 4:
- in.setKeyword(FileUtils.getCellValue(cell));
- break;
- case 5:
- in.setIsHot(Integer.valueOf(FileUtils.getCellValue(cell)));
- break;
- case 6:
- in.setIsUrgent(Integer.valueOf(FileUtils.getCellValue(cell)));
- break;
- case 7:
- in.setUrgentDays(Integer.valueOf(FileUtils.getCellValue(cell)));
- break;
- case 8:
- in.setUrgentMoney(new BigDecimal(FileUtils.getCellValue(cell)));
- break;
- }
- } catch (Exception e) {
- throw new BusinessException(new Error("表格第"+(rowNum+1)+"行输入内容不正确。"));
- }
- }
- if (!list2.isEmpty()) {
- StringBuffer str=new StringBuffer("[");
- for (String string : list2) {
- str.append(string+",");
- }
- str.deleteCharAt(str.length()-1);
- str.append("]");
- throw new BusinessException(new Error("名称"+str+"内容过长,请控制在512个字符内"));
- }
- in.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- in.setEmployerId(TokenManager.getAdminId());
- in.setCreateTime(date);
- in.setStatus(0);
- in.setReleaseStatus(AchievementAuditStatus.CREATE.getCode());
- in.setAuditStatus(0);
- in.setId(UUID.randomUUID().toString());
- in.setInfoSources(1);
- list.add(in);
- //关键字处理
- if(in.getKeyword()!=null) {
- String [] keywords=null;
- boolean flag= false;
- if (in.getKeyword().contains(",")) {
- keywords=in.getKeyword().split(",");
- flag=true;
- }else if (in.getKeyword().contains(",")) {
- keywords=in.getKeyword().split(",");
- flag=true;
- }else {
- DemandKeyword ak = new DemandKeyword();
- ak.setId(UUID.randomUUID().toString());
- ak.setDemandId(in.getId());
- ak.setKeyword(in.getKeyword());
- keyword.add(ak);
- }
- if (flag) {
- for (String string : keywords) {
- DemandKeyword ak = new DemandKeyword();
- ak.setId(UUID.randomUUID().toString());
- ak.setDemandId(in.getId());
- ak.setKeyword(string);
- keyword.add(ak);
- }
- }
- }
-
- DemandPublish ap = new DemandPublish();
- ap.setId(UUID.randomUUID().toString());
- ap.setDemandId((in.getId()));
- ap.setPublisher(TokenManager.getUserId());
- ap.setPublishTime(date);
- ap.setPublishClient(PageConstants.WEB_PLATFORM);
- ap.setPublishPage("wep_demand_list");
- ap.setPublishPlatform(defaultPlatformId);
- ap.setIfTop(AFTConstants.NO);
- ap.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
- ap.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
- publish.add(ap);
- DemandPublish ap2 = new DemandPublish();
- ap2.setId(UUID.randomUUID().toString());
- ap2.setDemandId(in.getId());
- ap2.setPublisher(TokenManager.getUserId());
- ap2.setPublishTime(date);
- ap2.setPublishClient(PageConstants.APP_PLATFORM);
- ap2.setPublishPage("app_demand_list");
- ap2.setPublishPlatform(defaultPlatformId);
- ap2.setIfTop(AFTConstants.NO);
- ap2.setTopNumber(PageConstants.DEFAULT_TOP_NUMBER);
- ap2.setShowNumber(PageConstants.DEFAULT_SHOW_NUMBER);
- publish.add(ap2);
-
- }
- demandMapper.insertBatch(list);
- demandKeywordMapper.insertBatch(keyword);
- demandPublishMapper.insertBatch(publish);
- }
-
-
- }
|