| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932 |
- package com.goafanti.achievement.service.impl;
- 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.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.cache.annotation.CacheEvict;
- import org.springframework.cache.annotation.Cacheable;
- import org.springframework.stereotype.Service;
- import com.goafanti.achievement.bo.AchievementImportBo;
- import com.goafanti.achievement.bo.AchievementListBo;
- import com.goafanti.achievement.bo.AchievementOrgOwnerDetailBo;
- import com.goafanti.achievement.bo.AchievementPartnerListBo;
- import com.goafanti.achievement.bo.AchievementUserOwnerDetailBo;
- import com.goafanti.achievement.service.AchievementService;
- import com.goafanti.common.bo.PolicyEntity;
- import com.goafanti.common.constant.AFTConstants;
- import com.goafanti.common.dao.AchievementDemandCountMapper;
- import com.goafanti.common.dao.AchievementDemandMapper;
- import com.goafanti.common.dao.AchievementInterestMapper;
- import com.goafanti.common.dao.AchievementKeywordMapper;
- import com.goafanti.common.dao.AchievementMapper;
- import com.goafanti.common.dao.DemandKeywordMapper;
- import com.goafanti.common.dao.NoticeMapper;
- import com.goafanti.common.dao.OrganizationIdentityMapper;
- import com.goafanti.common.dao.UserIdentityMapper;
- import com.goafanti.common.dao.UserMapper;
- import com.goafanti.common.dao.UserRoleMapper;
- import com.goafanti.common.enums.AchievementAuditStatus;
- import com.goafanti.common.enums.AchievementReleaseStatus;
- import com.goafanti.common.enums.AchievementSwitchSign;
- import com.goafanti.common.enums.DeleteStatus;
- import com.goafanti.common.enums.DemandReleaseStatus;
- import com.goafanti.common.enums.NoticeReadStatus;
- import com.goafanti.common.enums.NoticeStatus;
- import com.goafanti.common.enums.UserType;
- import com.goafanti.common.model.Achievement;
- import com.goafanti.common.model.AchievementDemand;
- import com.goafanti.common.model.AchievementDemandCount;
- import com.goafanti.common.model.AchievementKeyword;
- import com.goafanti.common.model.Admin;
- 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.LoggerUtils;
- 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.DemandAchievementListBo;
- import com.goafanti.portal.bo.AchievementDetailBo;
- import com.goafanti.portal.bo.AchievementObject;
- import com.goafanti.portal.bo.AchievementPortalDetailBo;
- import com.goafanti.portal.bo.AchievementPortalSimilarListBo;
- import com.goafanti.portal.bo.AchievementSearchListBo;
- import com.goafanti.portal.bo.BoutiqueListBo;
- import com.goafanti.portal.bo.InternationalListBo;
- @Service
- public class AchievementServiceImpl extends BaseMybatisDao<AchievementMapper> implements AchievementService {
- @Autowired
- private AchievementMapper achievementMapper;
- @Autowired
- private UserRoleMapper userRoleMapper;
- @Autowired
- private NoticeMapper noticeMapper;
- @Autowired
- private AchievementKeywordMapper achievementKeywordMapper;
- @Autowired
- private AchievementDemandMapper achievementDemandMapper;
- @Autowired
- private DemandKeywordMapper demandKeywordMapper;
- @Autowired
- private AchievementDemandCountMapper achievementDemandCountMapper;
- @Autowired
- private UserIdentityMapper userIdentityMapper;
- @Autowired
- private OrganizationIdentityMapper organizationIdentityMapper;
- @Autowired
- private AchievementInterestMapper achievementInterestMapper;
- @Autowired
- private UserMapper userMapper;
- private static final Logger logger = LoggerFactory.getLogger(AchievementServiceImpl.class);
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementListBo> listUserOwnerAchievement(Integer ownerType,String username, String ownerName, String ownerId,
- Integer auditStatus, Integer serialNumber, String name, String keyword, Integer category, Integer status,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, Integer pNo, Integer pSize,
- Integer boutique, Integer hot) {
- Map<String, Object> params = disposeParams(ownerType,username, ownerName, ownerId, auditStatus, serialNumber, name, keyword, category, status,
- releaseDateStartDate, releaseDateEndDate, createDateStartDate, createDateEndDate, releaseStatus, UserType.ORGANIZATION.getCode(),
- boutique,null, hot,null);
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.AUDITORADMIN)) {
- params.put("adminId", TokenManager.getAdminId());
- }
-
- return (Pagination<AchievementListBo>) findPage("findUserOwnerAchievementListByPage",
- "findUserOwnerAchievementCount",params,
- pNo, pSize);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementListBo> listOrgOwnerAchievement(Integer ownerType,String unitName, String ownerName, String ownerId,
- Integer auditStatus, Integer serialNumber, String name, String keyword, Integer category, Integer status,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, String internationalFlag,Integer pNo, Integer pSize,
- Integer boutique, Integer hot,String recordPerson) {
- Map<String, Object> params = disposeParams(ownerType,unitName, ownerName, ownerId, auditStatus, serialNumber, name, keyword, category, status,
- releaseDateStartDate, releaseDateEndDate, createDateStartDate, createDateEndDate, releaseStatus, UserType.ORGANIZATION.getCode(),
- boutique,internationalFlag, hot,recordPerson);
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
-
- return (Pagination<AchievementListBo>) findPage("findOrgOwnerAchievementListByPage",
- "findOrgOwnerAchievementCount",params,pNo, pSize);
- }
- @Override
- public void saveAchievement(Achievement a, String[] keywords) {
- a.setId(UUID.randomUUID().toString());
- a.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- if (TokenManager.getToken() instanceof Admin) {
- a.setTechBrokerId(TokenManager.getAdminId());
- }
- a.setReleaseStatus(AchievementReleaseStatus.UNRELEASE.getCode());
- if (AchievementAuditStatus.SUBMIT.getCode().equals(a.getAuditStatus())) {
-
- createAuditorNotice(a);
- } else {
- a.setAuditStatus(AchievementAuditStatus.CREATE.getCode());
- }
- Integer ownerType = a.getOwnerType();
- String ownerMobile = a.getOwnerMobile();
- String ownerName = a.getOwnerName();
- String ownerId = "";
- if (TokenManager.getToken() instanceof User) {
- a.setOwnerId(TokenManager.getUserId());
- User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
- if (null != u) {
- ownerId = u.getId();
- if(ownerType == null) ownerType = u.getType();
- if(StringUtils.isBlank(ownerMobile)) ownerMobile = u.getMobile();
- if(StringUtils.isBlank(ownerName)) ownerName = u.getNickname();
- // 如果是单位客户 -查询单位客户的邮件 和通讯地址、证件号码
- //TODO
- }
- }
- a.setCreateTime(now.getTime());
- a.setOwnerType(ownerType);
- a.setOwnerMobile(ownerMobile);
- a.setOwnerName(ownerName);
- a.setOrgId(ownerId);
- achievementMapper.insert(a);
- disposeAchievementKeyword(keywords, a, false);
- }
- @Override
- public int updateAchievement(Achievement a, String[] keywords, Integer switchSign) {
- if (AchievementAuditStatus.SUBMIT.getCode().equals(a.getAuditStatus())) {
- createAuditorNotice(a);
- }
- disposeAchievementKeyword(keywords, a, true);
- achievementMapper.updateByPrimaryKeySelective(a);
- if (null != switchSign && AchievementSwitchSign.CLOSE.getCode().equals(switchSign)) {
- achievementMapper.updateOwnerId(a.getId());
- }
- return 1;
- }
- @Override
- public Achievement selectByPrimaryKey(String id) {
- return achievementMapper.selectByPrimaryKey(id);
- }
- @Override
- public int deleteByPrimaryKey(List<String> id) {
- achievementKeywordMapper.batchDeleteByAchievementIds(id);
- achievementDemandMapper.batchDeleteByAchievementIds(id);
- for (String s : id) {
- Achievement a = achievementMapper.selectByPrimaryKey(s);
- if (null != a && AchievementAuditStatus.AUDITED.getCode().equals(a.getAuditStatus())
- && StringUtils.isNotBlank(a.getOwnerId())) {
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(a.getOwnerId());
- if (null != adc) {
- adc.setAchievementCount(adc.getAchievementCount() - 1);
- if (adc.getAchievementCount() < 0) {
- adc.setAchievementCount(0);
- }
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- }
- return achievementMapper.batchDeleteByPrimaryKey(id);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementListBo> listUserAchievement(Integer auditStatus, Integer serialNumber, String name,
- String keyword, Integer category, Integer ownerType, Integer status, String releaseDateStartDate,
- String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, Integer pNo, Integer pSize) {
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<AchievementListBo>) findPage("findAchievementListByPage", "findAchievementCount",
- disposeParams(ownerType,null, null, TokenManager.getUserId(), auditStatus, serialNumber, name, keyword, category,
- status, releaseDateStartDate, releaseDateEndDate,createDateStartDate,createDateEndDate, releaseStatus, null, null,null, null,null),
- pNo, pSize);
- }
- private Map<String, Object> disposeParams(Integer ownerType,String username, String ownerName, String ownerId, Integer auditStatus,
- Integer serialNumber, String name, String keyword, Integer category, Integer status,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, Integer type,
- Integer boutique,String internationalFlag, Integer hot,String recordPerson) {
- Map<String, Object> params = new HashMap<>();
- Date rStart = null;
- Date rEnd = null;
- Date cStart = null;
- Date cEnd = null;
- if (null != ownerType) {
- params.put("ownerType", ownerType);
- }
- if (null != recordPerson) {
- params.put("recordPerson", recordPerson);
- }
-
- 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 (StringUtils.isNotBlank(ownerName)) {
- params.put("ownerName", ownerName);
- }
- if (null != type && StringUtils.isNotBlank(username)) {
- if (UserType.PERSONAL.getCode().equals(type)) {
- params.put("username", username);
- } else {
- params.put("unitName", username);
- }
- }
- 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 (!StringUtils.isBlank(ownerId)) {
- params.put("ownerId", ownerId);
- }
- if (null != serialNumber) {
- params.put("serialNumber", serialNumber);
- }
- if (!StringUtils.isBlank(name)) {
- params.put("name", name);
- }
- if (!StringUtils.isBlank(keyword)) {
- params.put("keyword", keyword);
- }
- if (null != category) {
- params.put("category", category);
- }
- 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);
- }
- if (null != internationalFlag) {
- params.put("internationalFlag", internationalFlag);
- }
- if (!TokenManager.hasRole(AFTConstants.SUPERADMIN) && !TokenManager.hasRole(AFTConstants.AUDITORADMIN)) {
- params.put("techBrokerId", TokenManager.getAdminId());
- }
-
- return params;
- }
- @Override
- public int updateAuditAchievement(Achievement a, String techBroderId, Integer auditStatus) {
- a.setAuditStatus(auditStatus);
- if (AchievementAuditStatus.AUDITED.getCode().equals(auditStatus)) {
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- a.setReleaseDate(now.getTime());
- a.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- a.setTechBrokerId(techBroderId);
- if (StringUtils.isNotBlank(a.getKeyword())) {
- String[] keywords = a.getKeyword().trim().split(",|,");
- disposeAchievementKeyword(keywords, a, false);
- }
- String ownerId = a.getOwnerId();
- if (StringUtils.isNotBlank(ownerId)) {
- if (UserType.PERSONAL.getCode().equals(a.getOwnerType())) {
- UserIdentity ui = userIdentityMapper.selectUserIdentityByUserId(ownerId);
- if (null != ui) {
- a.setOwnerName(ui.getUsername());
- }
- } else if (UserType.ORGANIZATION.getCode().equals(a.getOwnerType())) {
- OrganizationIdentity oi = organizationIdentityMapper.selectOrgIdentityByUserId(ownerId);
- if (null != oi) {
- a.setOwnerName(oi.getUnitName());
- }
- }
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(ownerId);
- if (null == adc) {
- AchievementDemandCount achievementDemandCount = new AchievementDemandCount();
- achievementDemandCount.setId(UUID.randomUUID().toString());
- achievementDemandCount.setUid(ownerId);
- achievementDemandCount.setAchievementCount(AFTConstants.ACHIEVEMENT_DEMAND_FIRST_COUNT);
- achievementDemandCount.setDemandCount(AFTConstants.ACHIEVEMENT_DEMAND_INIT_COUNT);
- achievementDemandCountMapper.insert(achievementDemandCount);
- } else {
- adc.setAchievementCount(adc.getAchievementCount() + 1);
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- } else {
- a.setReleaseStatus(DemandReleaseStatus.UNRELEASE.getCode());
- }
- createTechBorkerNotice(a);
- return achievementMapper.updateByPrimaryKeySelective(a);
- }
- @Override
- public int updateReleaseStatus(Achievement a) {
- a.setAuditStatus(AchievementAuditStatus.AUDITED.getCode());
- if(a.getReleaseStatus()==1){
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- a.setReleaseDate(now.getTime());
- }
- achievementDemandMapper.deleteByAchievementId(a.getId());
- achievementKeywordMapper.batchDeleteByAchievementId(a.getId());
- int i=0;
- i=achievementMapper.updateByPrimaryKeySelective(a);
- if (StringUtils.isNotBlank(a.getOwnerId())) {
- AchievementDemandCount adc = achievementDemandCountMapper.selectByUid(a.getOwnerId());
- if (null != adc) {
- adc.setAchievementCount(adc.getAchievementCount() - 1);
- if (adc.getAchievementCount() < 0) {
- adc.setAchievementCount(0);
- }
- achievementDemandCountMapper.updateByPrimaryKeySelective(adc);
- }
- }
- return i;
- }
- @Override
- public AchievementUserOwnerDetailBo selectAppUserOwnerDetail(String id) {
- AchievementUserOwnerDetailBo a=achievementMapper.selectUserOwnerDetail(id);
- int i=achievementMapper.countInterest(a.getId());
- a.setCountInterest(String.valueOf(i));
- String uid=TokenManager.getUserId();
- if(TokenManager.isLogin()&&achievementInterestMapper.checkUidAndDid(uid,id)>0){
- a.setInterest("1");
- }else {
- a.setInterest("0");
- }
- return a;
- }
- @Override
- public AchievementOrgOwnerDetailBo selectOrgOwnerDetail(String id) {
- return achievementMapper.selectOrgOwnerDetail(id);
- }
-
- @Override
- public AchievementUserOwnerDetailBo selectUserOwnerDetail(String id) {
- return achievementMapper.selectUserOwnerDetail(id);
- }
- @Override
- public List<DemandAchievementListBo> selectAchievementDemandListByAchievementId(String id) {
- return achievementDemandMapper.selectAchievementDemandListByAchievementId(id);
- }
- @Override
- public void insertImport(List<AchievementImportBo> data) {
- if (null == data || data.isEmpty()) {
- return;
- }
- Achievement a = null;
- AchievementKeyword ak = null;
- List<Achievement> achievementList = new ArrayList<>();
- List<AchievementKeyword> AchievementKeywordList = new ArrayList<>();
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- String techBrokerId = TokenManager.hasRole(AFTConstants.TECHBROKER) ? TokenManager.getAdminId() : null;
- for (AchievementImportBo bo : data) {
- a = new Achievement();
- BeanUtils.copyProperties(bo, a);
- a.setId(UUID.randomUUID().toString());
- a.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- a.setCreateTime(now.getTime());
- a.setAuditStatus(AchievementAuditStatus.INAUDIT.getCode());
- a.setReleaseStatus(AchievementReleaseStatus.UNRELEASE.getCode());
- a.setTechBrokerId(techBrokerId);
- List<String> keywordsList = bo.getKeywords();
- if (null != keywordsList && keywordsList.size() > 0) {
- for (String s : keywordsList) {
- if (!StringUtils.isBlank(s)) {
- ak = new AchievementKeyword();
- ak.setAchievementId(a.getId());
- ak.setKeyword(s.trim());
- ak.setId(UUID.randomUUID().toString());
- AchievementKeywordList.add(ak);
- }
- }
- }
- achievementList.add(a);
- }
- achievementMapper.insertBatch(achievementList);
- achievementKeywordMapper.insertBatch(AchievementKeywordList);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementSearchListBo> listAchievementSearchList(String url,String keyword, Integer dataCategory,
- Integer category, Integer fieldA, String transferMode, Integer pNo, Integer pSize, Integer dateSort,
- String upperPrice, String lowerPrice,Integer internationalFlag) {
- Map<String, Object> params = new HashMap<>();
- if (!StringUtils.isBlank(url)) {
- params.put("url", url);
- }
- if (!StringUtils.isBlank(keyword)) {
- params.put("keyword", keyword);
- }
- if (null != dataCategory) {
- params.put("dataCategory", dataCategory);
- }
- if (null != category) {
- params.put("category", category);
- }
- if (null != fieldA) {
- params.put("fieldA", fieldA);
- }
- if (!StringUtils.isBlank(transferMode)) {
- params.put("transferMode", transferMode);
- }
- if (dateSort != null) {
- params.put("dateSort", dateSort);
- }
- if (upperPrice != null) {
- params.put("upperPrice", upperPrice);
- }
- if (lowerPrice != null) {
- params.put("lowerPrice", lowerPrice);
- }
- if (null !=internationalFlag ) {
- params.put("internationalFlag", internationalFlag);
- }
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 20) {
- pSize = 20;
- }
- Pagination<AchievementSearchListBo> result = (Pagination<AchievementSearchListBo>) findPage(
- "findSearchAchievementListByPage", "findSearchAchievementCount", params, pNo, pSize);
- List<AchievementSearchListBo> AchievementSearchList = (List<AchievementSearchListBo>) result.getList();
- for (int i = 0; i < AchievementSearchList.size(); i++) {
- String introduction = AchievementSearchList.get(i).getIntroduction();
- if (introduction != null)
- introduction = introduction.length() > 20 ? introduction.substring(0, 20) + "... ..." : introduction;
- }
- return result;
- }
- @Override
- public AchievementDetailBo selectAchievementSearchDetail(String uid, String id) {
- return achievementMapper.selectAchievementSearchDetail(uid, id);
- }
- private void createTechBorkerNotice(Achievement a) {
- // noticeMapper.insert(disposeNotice(a, null));
- }
- // 给所有审核员发送审核通知
- private void createAuditorNotice(Achievement a) {
- List<String> ids = userRoleMapper.listAuditor();
- List<Notice> list = new ArrayList<>();
- if (null != ids && ids.size() > 0) {
- for (String s : ids) {
- list.add(disposeNotice(a, s));
- }
- noticeMapper.insertBatch(list);
- }
- }
- private Notice disposeNotice(Achievement a, 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(a.getId());
- if (StringUtils.isBlank(aid)) {
- n.setAid(a.getTechBrokerId());
- if (UserType.PERSONAL.getCode().equals(a.getOwnerType())) {
- n.setContent("编号" + a.getSerialNumber() + NoticeStatus.PERSONALACHIEVEMENTT.getDesc() + " "
- + (AchievementAuditStatus.AUDITED.getCode().equals(a.getAuditStatus())
- ? AchievementAuditStatus.AUDITED.getDesc()
- : AchievementAuditStatus.UNAUDITED.getDesc()));
- n.setNoticeType(NoticeStatus.PERSONALACHIEVEMENTT.getCode());
- } else if (UserType.ORGANIZATION.getCode().equals(a.getOwnerType())) {
- n.setContent("编号" + a.getSerialNumber() + NoticeStatus.ORGANIZATIONACHIEVEMENT.getDesc() + " "
- + (AchievementAuditStatus.AUDITED.getCode().equals(a.getAuditStatus())
- ? AchievementAuditStatus.AUDITED.getDesc()
- : AchievementAuditStatus.UNAUDITED.getDesc()));
- n.setNoticeType(NoticeStatus.ORGANIZATIONACHIEVEMENT.getCode());
- }
- } else {
- n.setAid(aid);
- if (UserType.PERSONAL.getCode().equals(a.getOwnerType())) {
- n.setContent(
- NoticeStatus.PERSONALACHIEVEMENTT.getDesc() + " " + AchievementAuditStatus.SUBMIT.getDesc());
- n.setNoticeType(NoticeStatus.PERSONALACHIEVEMENTT.getCode());
- } else if (UserType.ORGANIZATION.getCode().equals(a.getOwnerType())) {
- n.setContent(
- NoticeStatus.ORGANIZATIONACHIEVEMENT.getDesc() + " " + AchievementAuditStatus.SUBMIT.getDesc());
- n.setNoticeType(NoticeStatus.ORGANIZATIONACHIEVEMENT.getCode());
- }
- }
- return n;
- }
- private void disposeAchievementKeyword(String[] keywords, Achievement a, boolean delete) {
- if (null != keywords && keywords.length > 0) {
- if (delete) {
- achievementKeywordMapper.batchDeleteByAchievementId(a.getId());
- }
- List<AchievementKeyword> list = new ArrayList<>();
- AchievementKeyword ak = null;
- for (int i = 0; i < keywords.length; i++) {
- ak = new AchievementKeyword();
- ak.setId(UUID.randomUUID().toString());
- ak.setAchievementId(a.getId());
- ak.setKeyword(keywords[i].trim());
- list.add(ak);
- }
- achievementKeywordMapper.insertBatch(list);
- }
- }
- @Override
- public int updateMatchDemand(Achievement a) {
- achievementDemandMapper.deleteByAchievementId(a.getId());// 删除之前匹配单
- List<AchievementKeyword> achievement = achievementKeywordMapper.selectKeywordsByAchievementId(a.getId());
- if (null != achievement && achievement.size() > 0) {
- List<String> keyword = new ArrayList<>();
- for (AchievementKeyword k : achievement) {
- if (!StringUtils.isBlank(k.getKeyword())) {
- keyword.add(k.getKeyword());
- }
- }
- List<AchievementDemand> list = demandKeywordMapper.selectAchievementDemand(keyword);
- if (null != list && list.size() > 0) {
- for (AchievementDemand ad : list) {
- ad.setAchievementId(a.getId());
- }
- return achievementDemandMapper.insertBatch(list);
- }
- }
- return 0;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementPartnerListBo> listPartnerAchievement(String ownerId, Integer pNo, Integer pSize) {
- Map<String, Object> params = new HashMap<>();
- params.put("ownerId", ownerId);
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- return (Pagination<AchievementPartnerListBo>) findPage("findPartnerAchievementListByPage",
- "findPartnerAchievementCount", params, pNo, pSize);
- }
- @Override
- public AchievementPortalDetailBo findUserPortalAchievementDetail(String id) {
- return achievementMapper.findUserPortalAchievementDetail(id, TokenManager.getUserId());
- }
- @Override
- public AchievementPortalDetailBo findOrgPortalAchievementDetail(String id) {
- return achievementMapper.findOrgPortalAchievementDetail(id, TokenManager.getUserId());
- }
- @Override
- public List<AchievementPortalSimilarListBo> findByFieldA(Integer fieldA, String id, Integer type) {
- if (UserType.PERSONAL.getCode().equals(type)) {
- return achievementMapper.findUserPortalSimilarByFieldA(fieldA, id);
- } else if (UserType.ORGANIZATION.getCode().equals(type)) {
- return achievementMapper.findOrgPortalSimilarByFieldA(fieldA, id);
- }
- return null;
- }
- @Override
- public int updateByPrimaryKeySelective(Achievement a) {
- return achievementMapper.updateByPrimaryKey(a);
- }
- @Override
- @Cacheable(value = "internationalAchievementList", key = "'internationalAchievementList:'+#internationalAchievementCacheKey")
- public List<InternationalListBo> selectInternationalAchievement(Integer internationalAchievementCacheKey) {
- return achievementMapper.selectInternationalAchievement();
- }
- @CacheEvict(value = "internationalAchievementList", allEntries = true)
- public void cleanInternationalAchievement() {
- LoggerUtils.debug(logger, "清除国际化技术列表");
- }
- @Override
- public Achievement selectAchievementDetail(String id) {
- return achievementMapper.selectByPrimaryKey(id);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<BoutiqueListBo> boutiqueSearchList(Integer dataCategory, Integer category, Integer fieldA,
- Integer pNo, Integer pSize) {
- Map<String, Object> params = new HashMap<>();
- if (null != dataCategory) {
- params.put("dataCategory", dataCategory);
- }
- if (null != category) {
- params.put("category", category);
- }
- if (null != fieldA) {
- params.put("fieldA", fieldA);
- }
- return (Pagination<BoutiqueListBo>) findPage("findBoutiqueListByPage", "findBoutiqueCount", params, pNo, pSize);
- }
- @Override
- public List<AchievementListBo> getAchievement(Integer boutique) {
- return achievementMapper.listAchievement();
- }
- @Override
- public List<AchievementListBo> getPerhapLike() {
- return achievementMapper.selectCsutomerLike(); //查询出猜你喜欢
- }
- @Override
- public List<AchievementPartnerListBo> findPartnerAchievementList(String uid) {
- return achievementMapper.findPartnerAchievementListByPage(uid);
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementPartnerListBo> listAppUserAchievement(Integer auditStatus, Integer serialNumber,
- String name, String keyword,Integer dataCategory, Integer category, Integer ownerType, Integer status,
- String releaseDateStartDate, String releaseDateEndDate, Integer releaseStatus,String ownerId,Integer fieldA, Integer pNo, Integer pSize) {
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- Map<String, Object> params=disposeParams(ownerType,null, null, ownerId, auditStatus, serialNumber, name, keyword, category,
- status, releaseDateStartDate, releaseDateEndDate,null, null, releaseStatus, null, null,null, null,null);
- if (null!=fieldA) {
- params.put("fieldA", fieldA);
- }
- if (null != dataCategory) {
- params.put("dataCategory", dataCategory);
- }
- Pagination<AchievementPartnerListBo> p=(Pagination<AchievementPartnerListBo>) findPage("findAppAchievementListByPage", "findAppAchievementCount",
- params,pNo, pSize);
-
- return p;
- }
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementPartnerListBo> listAppMyAchievement(Integer pNo, Integer pSize) {
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
- Map<String, Object> params = new HashMap<>();
- if (StringUtils.isNotBlank(TokenManager.getUserId())) {
- params.put("ownerId", TokenManager.getUserId());
- }
- //params.put("ownerId", "46433140-0a90-471e-a32f-6bc89c562e3d");
- return (Pagination<AchievementPartnerListBo>) findPage("findMyAchievementListByPage", "findMyAchievementCount",
- params,pNo, pSize);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementListBo> listMyAchievement(String techBrokerId,Integer ownerType,String unitName, String ownerName, String ownerId,
- Integer auditStatus, Integer serialNumber, String name, String keyword, Integer category, Integer status,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, String internationalFlag,Integer pNo, Integer pSize,
- Integer boutique, Integer hot) {
- Map<String, Object> params = disposeParams(ownerType,unitName, ownerName, ownerId, auditStatus, serialNumber, name, keyword, category, status,
- releaseDateStartDate, releaseDateEndDate, createDateStartDate, createDateEndDate, releaseStatus, UserType.ORGANIZATION.getCode(),
- boutique,internationalFlag, hot,null);
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
-
- if (null != techBrokerId) {
- params.put("techBrokerId", techBrokerId);
- }
-
- return (Pagination<AchievementListBo>) findPage("findMyyAchievementListByPage",
- "findMyyAchievementCount",params,pNo, pSize);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Pagination<AchievementListBo> listManageAchievement(String techBrokerId,Integer ownerType,String unitName, String ownerName, String ownerId,
- Integer auditStatus, Integer serialNumber, String name, String keyword, Integer category, Integer status,
- String releaseDateStartDate, String releaseDateEndDate,String createDateStartDate, String createDateEndDate, Integer releaseStatus, String internationalFlag,Integer pNo, Integer pSize,
- Integer boutique, Integer hot,String recordPerson) {
- Map<String, Object> params = disposeParams(ownerType,unitName, ownerName, ownerId, auditStatus, serialNumber, name, keyword, category, status,
- releaseDateStartDate, releaseDateEndDate, createDateStartDate, createDateEndDate, releaseStatus, UserType.ORGANIZATION.getCode(),
- boutique,internationalFlag, hot,recordPerson);
- if (pNo == null || pNo < 0) {
- pNo = 1;
- }
- if (pSize == null || pSize < 0 || pSize > 10) {
- pSize = 10;
- }
-
- if (null != techBrokerId) {
- params.put("techBrokerId", techBrokerId);
- }
-
- return (Pagination<AchievementListBo>) findPage("findManageAchievementListByPage",
- "findManageAchievementCount",params,pNo, pSize);
- }
- @Override
- public int saveAppAchievement(Achievement a, String[] keywords) {
- a.setId(UUID.randomUUID().toString());
- a.setDeletedSign(DeleteStatus.UNDELETE.getCode());
- Calendar now = Calendar.getInstance();
- now.set(Calendar.MILLISECOND, 0);
- if (TokenManager.getToken() instanceof Admin) {
- a.setTechBrokerId(TokenManager.getAdminId());
- }
- a.setReleaseStatus(AchievementReleaseStatus.UNRELEASE.getCode());
- if (AchievementAuditStatus.SUBMIT.getCode().equals(a.getAuditStatus())) {
- createAuditorNotice(a);
- } else {
- a.setAuditStatus(AchievementAuditStatus.INAUDIT.getCode());
- }
- if (null!=TokenManager.getUserId()) {
- a.setOwnerId(TokenManager.getUserId());
- User u=userMapper.selectByPrimaryKey(TokenManager.getUserId());
- if (null!=u.getType()) {
- a.setOwnerType(u.getType());
- }if (StringUtils.isNotBlank(u.getMobile())) {
- a.setOwnerMobile(u.getMobile());
- }if (StringUtils.isNotBlank(u.getNickname())) {
- a.setOwnerName(u.getNickname());
- }
- }
- a.setDataCategory(0);
- a.setCreateTime(now.getTime());
- disposeAchievementKeyword(keywords, a, false);
- return achievementMapper.insert(a);
- }
- @Override
- public List<AchievementObject> recentAchievements(int size, String url, String showLocation) {
- // TODO Auto-generated method stub
- return achievementMapper.getRecentAchievements(size,url,showLocation);
- }
- @Override
- public List<AchievementObject> getHotAchievements(int size, String url, String showLocation) {
- // TODO Auto-generated method stub
- return achievementMapper.getHotAchievements( size, url, showLocation);
- }
- @Override
- public List<AchievementObject> getPatentList(int size, String url, String showLocation) {
- // TODO Auto-generated method stub
- return achievementMapper.getPatentList(size,url,showLocation);
- }
- @Override
- public List<AchievementObject> getPracticalTechnologys(int size, String url, String showLocation) {
- // TODO Auto-generated method stub
- return achievementMapper.getPracticalTechnologys(size,url,showLocation);
- }
- @Override
- public List<PolicyEntity> getIntellectualProperty(int size) {
- // TODO Auto-generated method stub
- return achievementMapper.getIntellectualProperty(size);
- }
- @Override
- public AchievementObject getAchievementDetail(String id, Integer type) {
- // TODO Auto-generated method stub
- return achievementMapper.getAchievementDetail(id,type);
- }
- @Override
- public List<AchievementObject> getBoutiquePatent(int size) {
- // TODO Auto-generated method stub
- return achievementMapper.getBoutiquePatent( size);
- }
- @Override
- public List<AchievementObject> guessYouLike(int size) {
- // TODO Auto-generated method stub
- return achievementMapper.guessYouLike(size);
- }
-
-
-
-
- }
|