|
|
@ -17,6 +17,7 @@ |
|
|
|
|
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
@ -27,15 +28,16 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.dao.SpecialSubjectDao; |
|
|
|
import com.epmet.dto.SpecialSubjectDTO; |
|
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
|
import com.epmet.dto.form.AddSpecialSubjectFormDTO; |
|
|
|
import com.epmet.dto.form.DelSpecialSubjectFormDTO; |
|
|
|
import com.epmet.dto.form.QuerySpecialSubFormDTO; |
|
|
|
import com.epmet.dto.result.AddSpecialSubjectResultDTO; |
|
|
|
import com.epmet.dto.result.WorkSpecialSubjectResultDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.SpecialSubjectEntity; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.redis.TagRedis; |
|
|
|
import com.epmet.service.ArticleService; |
|
|
|
import com.epmet.service.SpecialSubjectService; |
|
|
|
import com.epmet.service.TagCustomerService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -45,11 +47,13 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
/** |
|
|
|
* 专题表 |
|
|
@ -62,6 +66,12 @@ import java.util.stream.Collectors; |
|
|
|
public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService { |
|
|
|
@Autowired |
|
|
|
private TagCustomerService tagCustomerService; |
|
|
|
@Resource |
|
|
|
private TagRedis tagRedis; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
@Resource |
|
|
|
private ArticleService articleService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<SpecialSubjectDTO> page(Map<String, Object> params) { |
|
|
@ -115,6 +125,7 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 添加专题 |
|
|
|
* |
|
|
@ -131,13 +142,27 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
throw new RenException(EpmetErrorCode.TAG_NOT_EXIST.getCode(), EpmetErrorCode.TAG_NOT_EXIST.getMsg()); |
|
|
|
} |
|
|
|
//2、校验当前组织是否添加过此专题
|
|
|
|
SpecialSubjectEntity havedEntity = baseDao.selectByOrgIdAndTagId(formDTO.getOrgId(), formDTO.getTagId()); |
|
|
|
if (null != havedEntity) { |
|
|
|
throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); |
|
|
|
} |
|
|
|
QuerySpecialSubFormDTO querySpecialSubFormDTO=new QuerySpecialSubFormDTO(); |
|
|
|
querySpecialSubFormDTO.setOrgId(formDTO.getOrgId()); |
|
|
|
querySpecialSubFormDTO.setPids(formDTO.getPids()); |
|
|
|
List<WorkSpecialSubjectResultDTO> havedList=this.queryExistedList(querySpecialSubFormDTO); |
|
|
|
List<String> haveTagIds=havedList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
|
haveTagIds.forEach(tagId->{ |
|
|
|
if(tagId.equals(formDTO.getTagId())){ |
|
|
|
throw new RenException(EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getCode(), EpmetErrorCode.EXISTED_SPECIAL_PROJECT.getMsg()); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 3、保存
|
|
|
|
SpecialSubjectEntity insertEntity = ConvertUtils.sourceToTarget(formDTO, SpecialSubjectEntity.class); |
|
|
|
StaffInfoFromDTO staffInfoFromDTO = new StaffInfoFromDTO(); |
|
|
|
staffInfoFromDTO.setStaffId(formDTO.getAddUserId()); |
|
|
|
Result<MineResultDTO> result = govOrgOpenFeignClient.queryStaffProfile(staffInfoFromDTO); |
|
|
|
if(result.success()&&null!=result.getData()){ |
|
|
|
insertEntity.setAddUserAgencyId(result.getData().getAgencyId()); |
|
|
|
} |
|
|
|
insertEntity.setAddOrgId(formDTO.getOrgId()); |
|
|
|
insertEntity.setAddOrgPid(formDTO.getPid()); |
|
|
|
insertEntity.setAddOrgPids(formDTO.getPids()); |
|
|
|
baseDao.insert(insertEntity); |
|
|
|
return new AddSpecialSubjectResultDTO(insertEntity.getId()); |
|
|
|
} |
|
|
@ -183,16 +208,21 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
result.setTagId(dto.getTagId()); |
|
|
|
result.setTagName(dto.getTagName()); |
|
|
|
result.setCanDel(true); |
|
|
|
result.setAddOrgId(dto.getAddOrgId()); |
|
|
|
result.setOrgLevel(dto.getOrgLevel()); |
|
|
|
currentOrgList.add(result); |
|
|
|
}); |
|
|
|
if (CollectionUtils.isNotEmpty(currentOrgList)) { |
|
|
|
notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getSpecialSubjectId).distinct().collect(Collectors.toList()); |
|
|
|
notList = currentOrgList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
|
} |
|
|
|
if (!NumConstant.ZERO_STR.equals(formDTO.getPids())) { |
|
|
|
//存在上级组织...,从上往下查
|
|
|
|
List<String> pidList = Arrays.asList(formDTO.getPids().split(StrConstant.COLON)); |
|
|
|
for (String pid : pidList) { |
|
|
|
//优先展示自己的,所以要排除掉 领导们给我建立的专题
|
|
|
|
if(CollectionUtils.isNotEmpty(resultDTOList)){ |
|
|
|
List<String> parentAddList=resultDTOList.stream().map(WorkSpecialSubjectResultDTO::getTagId).distinct().collect(Collectors.toList()); |
|
|
|
notList.addAll(parentAddList); |
|
|
|
} |
|
|
|
//优先展示自己的,所以要排除掉自己的,自上向下查,优先展示上层领导们给我建立的专题
|
|
|
|
List<SpecialSubjectDTO> list = baseDao.queryExistedList(pid, notList); |
|
|
|
list.forEach(dto -> { |
|
|
|
WorkSpecialSubjectResultDTO result = new WorkSpecialSubjectResultDTO(); |
|
|
@ -200,6 +230,8 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
result.setTagId(dto.getTagId()); |
|
|
|
result.setTagName(dto.getTagName()); |
|
|
|
result.setCanDel(false); |
|
|
|
result.setAddOrgId(dto.getAddOrgId()); |
|
|
|
result.setOrgLevel(dto.getOrgLevel()); |
|
|
|
resultDTOList.add(result); |
|
|
|
}); |
|
|
|
} |
|
|
@ -210,4 +242,54 @@ public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao |
|
|
|
} |
|
|
|
return resultDTOList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 热门标签列表 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return java.util.List<com.epmet.dto.result.TagInfoResultDTO> |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2021/7/15 15:35 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<TagInfoResultDTO> hotSubjectTagList(HotSubjectTagFormDTO formDTO) { |
|
|
|
|
|
|
|
List<TagInfoResultDTO> list = tagRedis.zRevRange(formDTO.getCustomerId()); |
|
|
|
List<String> orgIds = Stream.of(formDTO.getPids().split(StrConstant.COLON)).collect(Collectors.toList()); |
|
|
|
orgIds.add(formDTO.getOrgId()); |
|
|
|
LambdaQueryWrapper<SpecialSubjectEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(SpecialSubjectEntity :: getCustomerId, formDTO.getCustomerId()); |
|
|
|
wrapper.eq(SpecialSubjectEntity :: getDelFlag, NumConstant.ZERO_STR); |
|
|
|
wrapper.in(SpecialSubjectEntity :: getAddOrgId, orgIds); |
|
|
|
List<SpecialSubjectEntity> specialSubjectList = baseDao.selectList(wrapper); |
|
|
|
if (CollectionUtils.isNotEmpty(specialSubjectList)) { |
|
|
|
List<String> tags = specialSubjectList.stream().map(SpecialSubjectEntity :: getTagId).distinct().collect(Collectors.toList()); |
|
|
|
list = list.stream().filter(item -> !tags.contains(item.getTagId())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 效果预览 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return java.util.List<com.epmet.dto.result.PreviewResultDTO> |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2021/7/16 14:28 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<PreviewResultDTO> preview(PreviewFormDTO formDTO) { |
|
|
|
List<PreviewResultDTO> result = new ArrayList<>(); |
|
|
|
formDTO.getTagIdList().forEach(tagId -> { |
|
|
|
PreviewResultDTO previewResultDTO = new PreviewResultDTO(); |
|
|
|
SpecialSubjectEntity subjectEntity = baseDao.getInfo(tagId); |
|
|
|
previewResultDTO.setSpecialSubjectId(subjectEntity.getId()); |
|
|
|
previewResultDTO.setTagName(subjectEntity.getTagName()); |
|
|
|
previewResultDTO.setArticleList(articleService.getArticleListByTag(tagId, formDTO.getPageNo(), formDTO.getPageSize())); |
|
|
|
result.add(previewResultDTO); |
|
|
|
}); |
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |