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 * @author zxc
* @date 2020/12/10 下午2:16 * @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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; 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.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils; 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.entity.IssueProjectTagDictEntity;
import com.epmet.redis.IssueProjectTagDictRedis; import com.epmet.redis.IssueProjectTagDictRedis;
import com.epmet.service.IssueProjectTagDictService; import com.epmet.service.IssueProjectTagDictService;
import com.epmet.utils.ModuleConstants;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
/** /**
* 议题项目标签字典表 * 议题项目标签字典表
@ -117,8 +118,10 @@ public class IssueProjectTagDictServiceImpl extends BaseServiceImpl<IssueProject
@Override @Override
public TagListResultDTO getTagList(TokenDto tokenDto, TagListFormDTO formDTO) { public TagListResultDTO getTagList(TokenDto tokenDto, TagListFormDTO formDTO) {
TagListResultDTO result = new TagListResultDTO(); TagListResultDTO result = new TagListResultDTO();
List<IssueCategoryTagResultDTO> defaultList = baseDao.selectDefaultList(tokenDto.getCustomerId(), formDTO.getCategoryIdList()); Map<String,List<IssueCategoryTagResultDTO>> map = issueProjectTagDictRedis.getTagsOrderByRank(tokenDto.getCustomerId(),
result.setDefaulted(defaultList); 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; 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)){ if (!CollectionUtils.isEmpty(tags)){
tags.forEach(t -> { tags.forEach(t -> {
// 缓存标签 -1 // 缓存标签 -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; // 数据库有关标签使用次数 -1 0:+1 ; 1:-1;
issueProjectTagDictDao.updateTagsUseCount(tags,customerId,NumConstant.ONE_STR); issueProjectTagDictDao.updateTagsUseCount(tags,customerId,NumConstant.ONE_STR);
@ -189,14 +192,17 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
return; return;
} }
List<IssueTagFormDTO> selectTags = form.getTagList(); List<IssueTagFormDTO> selectTags = form.getTagList();
List<IssueTagFormDTO> newTags = issueProjectTagDictDao.selectTagId(selectTags, customerId); List<IssueTagFormDTO> newTags = issueProjectTagDictDao.selectTagId(selectTags);
IssueTagsDTO issueTagsDTO = baseDao.selectOneTagByIssueId(form.getIssueId()); IssueTagsDTO issueTagsDTO = baseDao.selectOneTagByIssueId(form.getIssueId());
if (!CollectionUtils.isEmpty(newTags)){ if (!CollectionUtils.isEmpty(newTags)){
// 需要删除的标签 // 需要删除的标签
List<IssueTagFormDTO> delList = tags.stream().filter(tag -> !newTags.contains(tag)).collect(toList()); List<IssueTagFormDTO> delList = tags.stream().filter(tag -> !newTags.contains(tag)).collect(toList());
if (!CollectionUtils.isEmpty(delList)){ if (!CollectionUtils.isEmpty(delList)){
delList.forEach(d -> { 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; // 数据库有关标签使用次数 -1 0:+1 ; 1:-1;
issueProjectTagDictDao.updateTagsUseCount(delList,customerId,NumConstant.ONE_STR); issueProjectTagDictDao.updateTagsUseCount(delList,customerId,NumConstant.ONE_STR);
@ -206,7 +212,10 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag
if (!CollectionUtils.isEmpty(addList)){ if (!CollectionUtils.isEmpty(addList)){
addList.forEach(a -> { addList.forEach(a -> {
// 缓存标签+1 // 缓存标签+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 // 数据库对应标签 议题使用次数 +1
issueProjectTagDictDao.updateTagsUseCount(addList,customerId,NumConstant.ZERO_STR); 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> </if>
<where> <where>
DEL_FLAG = 0 DEL_FLAG = 0
AND CUSTOMER_ID = #{customerId}
AND AND
<foreach collection="tags" item="t" open=" ( " separator=" OR " close=" ) "> <foreach collection="tags" item="t" open=" ( " separator=" OR " close=" ) ">
CATEGORY_ID = #{t.id} id = #{t.id}
AND TAG_NAME = #{t.tagName}
</foreach> </foreach>
</where> </where>
</update> </update>
@ -32,7 +30,7 @@
FROM issue_project_tag_dict FROM issue_project_tag_dict
WHERE DEL_FLAG = 0 WHERE DEL_FLAG = 0
AND AND
<foreach collection="tags" item="t" separator="or" open="(" close=")"> <foreach collection="list" item="t" separator="or" open="(" close=")">
ID = #{t.id} ID = #{t.id}
</foreach> </foreach>
</select> </select>

Loading…
Cancel
Save