Browse Source

Merge remote-tracking branch 'origin/dev_issue_category' into dev_issue_category

dev_shibei_match
wangchao 5 years ago
parent
commit
c3e5346c33
  1. 2
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java
  2. 13
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java
  3. 17
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueTagsServiceImpl.java
  4. 6
      epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml

2
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/dao/IssueProjectTagDictDao.java

@ -51,7 +51,7 @@ public interface IssueProjectTagDictDao extends BaseDao<IssueProjectTagDictEntit
* @author zxc
* @date 2020/12/10 下午2:16
*/
List<IssueTagFormDTO> selectTagId(@Param("tags") List<IssueTagFormDTO> newTags, @Param("customerId")String customerId);
List<IssueTagFormDTO> selectTagId(@Param("list") List<IssueTagFormDTO> newTags);
/**
* 获取客户默认分类标签

13
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueProjectTagDictServiceImpl.java

@ -20,6 +20,7 @@ package com.epmet.service.impl;
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.NumConstant;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -32,14 +33,14 @@ import com.epmet.dto.result.TagListResultDTO;
import com.epmet.entity.IssueProjectTagDictEntity;
import com.epmet.redis.IssueProjectTagDictRedis;
import com.epmet.service.IssueProjectTagDictService;
import com.epmet.utils.ModuleConstants;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
* 议题项目标签字典表
@ -117,8 +118,10 @@ public class IssueProjectTagDictServiceImpl extends BaseServiceImpl<IssueProject
@Override
public TagListResultDTO getTagList(TokenDto tokenDto, TagListFormDTO formDTO) {
TagListResultDTO result = new TagListResultDTO();
List<IssueCategoryTagResultDTO> defaultList = baseDao.selectDefaultList(tokenDto.getCustomerId(), formDTO.getCategoryIdList());
result.setDefaulted(defaultList);
Map<String,List<IssueCategoryTagResultDTO>> map = issueProjectTagDictRedis.getTagsOrderByRank(tokenDto.getCustomerId(),
formDTO.getCategoryIdList());
result.setDefaulted(map.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME));
result.setCustomized(map.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME).stream().limit(NumConstant.TEN).collect(Collectors.toList()));
return result;
}

17
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueTagsServiceImpl.java

@ -179,7 +179,10 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
if (!CollectionUtils.isEmpty(tags)){
tags.forEach(t -> {
// 缓存标签 -1
dictRedis.editTagUseCount(customerId,t.getCategoryId(),t,NumConstant.ONE_STR);
IssueCategoryTagResultDTO issueCategoryTagResultDTO = new IssueCategoryTagResultDTO();
issueCategoryTagResultDTO.setName(t.getTagName());
issueCategoryTagResultDTO.setId(t.getId());
dictRedis.editTagUseCount(customerId,t.getCategoryId(),issueCategoryTagResultDTO,NumConstant.ONE_STR);
});
// 数据库有关标签使用次数 -1 0:+1 ; 1:-1;
issueProjectTagDictDao.updateTagsUseCount(tags,customerId,NumConstant.ONE_STR);
@ -189,14 +192,17 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
return;
}
List<IssueTagFormDTO> selectTags = form.getTagList();
List<IssueTagFormDTO> newTags = issueProjectTagDictDao.selectTagId(selectTags, customerId);
List<IssueTagFormDTO> newTags = issueProjectTagDictDao.selectTagId(selectTags);
IssueTagsDTO issueTagsDTO = baseDao.selectOneTagByIssueId(form.getIssueId());
if (!CollectionUtils.isEmpty(newTags)){
// 需要删除的标签
List<IssueTagFormDTO> delList = tags.stream().filter(tag -> !newTags.contains(tag)).collect(toList());
if (!CollectionUtils.isEmpty(delList)){
delList.forEach(d -> {
dictRedis.editTagUseCount(customerId,d.getCategoryId(),d,NumConstant.ONE_STR);
IssueCategoryTagResultDTO issueCategoryTagResultDTO = new IssueCategoryTagResultDTO();
issueCategoryTagResultDTO.setName(d.getTagName());
issueCategoryTagResultDTO.setId(d.getId());
dictRedis.editTagUseCount(customerId,d.getCategoryId(),issueCategoryTagResultDTO,NumConstant.ONE_STR);
});
// 数据库有关标签使用次数 -1 0:+1 ; 1:-1;
issueProjectTagDictDao.updateTagsUseCount(delList,customerId,NumConstant.ONE_STR);
@ -206,7 +212,10 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
if (!CollectionUtils.isEmpty(addList)){
addList.forEach(a -> {
// 缓存标签+1
dictRedis.editTagUseCount(customerId,a.getCategoryId(),a,NumConstant.ZERO_STR);
IssueCategoryTagResultDTO issueCategoryTagResultDTO = new IssueCategoryTagResultDTO();
issueCategoryTagResultDTO.setName(a.getTagName());
issueCategoryTagResultDTO.setId(a.getId());
dictRedis.editTagUseCount(customerId,a.getCategoryId(),issueCategoryTagResultDTO,NumConstant.ZERO_STR);
});
// 数据库对应标签 议题使用次数 +1
issueProjectTagDictDao.updateTagsUseCount(addList,customerId,NumConstant.ZERO_STR);

6
epmet-module/gov-issue/gov-issue-server/src/main/resources/mapper/IssueProjectTagDictDao.xml

@ -14,11 +14,9 @@
</if>
<where>
DEL_FLAG = 0
AND CUSTOMER_ID = #{customerId}
AND
<foreach collection="tags" item="t" open=" ( " separator=" OR " close=" ) ">
CATEGORY_ID = #{t.id}
AND TAG_NAME = #{t.tagName}
id = #{t.id}
</foreach>
</where>
</update>
@ -32,7 +30,7 @@
FROM issue_project_tag_dict
WHERE DEL_FLAG = 0
AND
<foreach collection="tags" item="t" separator="or" open="(" close=")">
<foreach collection="list" item="t" separator="or" open="(" close=")">
ID = #{t.id}
</foreach>
</select>

Loading…
Cancel
Save