|
|
@ -17,7 +17,12 @@ |
|
|
|
|
|
|
|
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; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
@ -26,6 +31,8 @@ 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.form.HotSubjectTagFormDTO; |
|
|
|
import com.epmet.dto.result.TagInfoResultDTO; |
|
|
|
import com.epmet.dto.TagCustomerDTO; |
|
|
|
import com.epmet.dto.form.AddSpecialSubjectFormDTO; |
|
|
|
import com.epmet.dto.form.DelSpecialSubjectFormDTO; |
|
|
@ -35,18 +42,22 @@ import com.epmet.dto.result.AddSpecialSubjectResultDTO; |
|
|
|
import com.epmet.dto.result.MineResultDTO; |
|
|
|
import com.epmet.dto.result.WorkSpecialSubjectResultDTO; |
|
|
|
import com.epmet.entity.SpecialSubjectEntity; |
|
|
|
import com.epmet.redis.TagRedis; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.service.SpecialSubjectService; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import com.epmet.service.TagCustomerService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
/** |
|
|
|
* 专题表 |
|
|
@ -59,6 +70,61 @@ import java.util.stream.Collectors; |
|
|
|
public class SpecialSubjectServiceImpl extends BaseServiceImpl<SpecialSubjectDao, SpecialSubjectEntity> implements SpecialSubjectService { |
|
|
|
@Autowired |
|
|
|
private TagCustomerService tagCustomerService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private TagRedis tagRedis; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<SpecialSubjectDTO> page(Map<String, Object> params) { |
|
|
|
IPage<SpecialSubjectEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, SpecialSubjectDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<SpecialSubjectDTO> list(Map<String, Object> params) { |
|
|
|
List<SpecialSubjectEntity> entityList = baseDao.selectList(getWrapper(params)); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entityList, SpecialSubjectDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
private QueryWrapper<SpecialSubjectEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<SpecialSubjectEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
|
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public SpecialSubjectDTO get(String id) { |
|
|
|
SpecialSubjectEntity entity = baseDao.selectById(id); |
|
|
|
return ConvertUtils.sourceToTarget(entity, SpecialSubjectDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(SpecialSubjectDTO dto) { |
|
|
|
SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(SpecialSubjectDTO dto) { |
|
|
|
SpecialSubjectEntity entity = ConvertUtils.sourceToTarget(dto, SpecialSubjectEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
|
|
|
@ -178,4 +244,30 @@ 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; |
|
|
|
} |
|
|
|
|
|
|
|
} |