Browse Source

标签查询时的补偿机制修改

dev_shibei_match
wangchao 4 years ago
parent
commit
19fbf37800
  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/redis/IssueProjectTagDictRedis.java
  3. 23
      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

@ -85,7 +85,7 @@ public interface IssueProjectTagDictDao extends BaseDao<IssueProjectTagDictEntit
List<IssueProjectTagDictEntity> selectTagListByCustomer(@Param("customerId") String customerId); List<IssueProjectTagDictEntity> selectTagListByCustomer(@Param("customerId") String customerId);
/** /**
* @Description 根据类别查询客户下标签 * @Description 根据类别查询客户下默认标签
* @param categories * @param categories
* @param customerId * @param customerId
* @return java.util.List<com.epmet.entity.IssueProjectTagDictEntity> * @return java.util.List<com.epmet.entity.IssueProjectTagDictEntity>

13
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java

@ -269,26 +269,31 @@ public class IssueProjectTagDictRedis {
CategoryTagInitFormDTO customerIdParam = new CategoryTagInitFormDTO(); CategoryTagInitFormDTO customerIdParam = new CategoryTagInitFormDTO();
customerIdParam.setCustomerId(customerId); customerIdParam.setCustomerId(customerId);
if (!CollectionUtils.isEmpty(redisUtils.keys(GovIssueRedisKeys.getGovernmentTagKey(customerId, null)))){ if (!CollectionUtils.isEmpty(redisUtils.keys(GovIssueRedisKeys.getGovernmentTagKey(customerId, null)))){
//缓存不为空
if(CollectionUtils.isEmpty(preResult) || CollectionUtils.isEmpty(preResult.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME))) { if(CollectionUtils.isEmpty(preResult) || CollectionUtils.isEmpty(preResult.get(ModuleConstants.DEFAULT_TAG_CATEGORY_NAME))) {
if (ifOtherOnly || CollectionUtils.isEmpty(category)) { if (ifOtherOnly || CollectionUtils.isEmpty(category)) {
//补偿全部默认标签 //补偿全部默认标签
categoryDictService.init(customerIdParam); categoryDictService.init(customerIdParam);
db.addAll(poolDao.selectTagListByCustomer(customerId)); db.addAll(poolDao.selectTagByCategory(null, customerId, customerId));
} else { } else {
if (NumConstant.ZERO <= poolDao.selectCountByCustomerId(customerId)) { if (NumConstant.ZERO <= poolDao.selectCountByCustomerId(customerId)) {
categoryDictService.init(customerIdParam); categoryDictService.init(customerIdParam);
} else { } else {
//只插入category中的标签 //只插入category中的标签
tagDictService.insertBatch(poolDao.selectTagByCategory(category, "default", customerId)); List<IssueProjectTagDictEntity> missingTags = poolDao.selectTagByCategory(category, "default", customerId);
db.addAll(poolDao.selectTagsByCustomerIdAndTagIds(customerId, category)); if(!CollectionUtils.isEmpty(missingTags)){
tagDictService.insertBatch(missingTags);
db.addAll(missingTags);}
} }
} }
} }
}else{ }else{
//缓存为空
if (NumConstant.ZERO <= poolDao.selectCountByCustomerId(customerId)) { if (NumConstant.ZERO <= poolDao.selectCountByCustomerId(customerId)) {
categoryDictService.init(customerIdParam); categoryDictService.init(customerIdParam);
} }
db.addAll(poolDao.selectTagListByCustomer(customerId)); db.addAll(poolDao.selectTagByCategory(null, customerId, customerId));
} }
if(CollectionUtils.isEmpty(preResult) || CollectionUtils.isEmpty(preResult.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME))){ if(CollectionUtils.isEmpty(preResult) || CollectionUtils.isEmpty(preResult.get(ModuleConstants.CUSTOMIZED_TAG_CATEGORY_NAME))){

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

@ -92,16 +92,31 @@
<if test='null != targetCustomerId and "" != targetCustomerId'> <if test='null != targetCustomerId and "" != targetCustomerId'>
#{targetCustomerId} as customerId, #{targetCustomerId} as customerId,
</if> </if>
TAG_NAME,CATEGORY_ID,IS_DEFAULT,ISSUE_USE_COUNT,PROJECT_USE_COUNT,IS_DISABLE,DEL_FLAG,REVISION TAG_NAME,CATEGORY_ID,IS_DEFAULT,
<choose>
<when test='"default" == customerId'>
ISSUE_USE_COUNT,
</when>
<otherwise>
IFNULL(ISSUE_USE_COUNT,0)+IFNULL(PROJECT_USE_COUNT,0) AS issueUseCount,
</otherwise>
</choose>
PROJECT_USE_COUNT,
IS_DISABLE,DEL_FLAG,REVISION
FROM FROM
ISSUE_PROJECT_TAG_DICT ISSUE_PROJECT_TAG_DICT
WHERE WHERE
DEL_FLAG = '0' DEL_FLAG = '0'
AND AND
CUSTOMER_ID = #{customerId} CUSTOMER_ID = #{customerId}
<foreach collection="categories" item="categoryId" open="AND ( " separator=" OR " close=" )"> AND
CATEGORY_ID = #{categoryId} IS_DEFAULT = '0'
</foreach> <if test="null != categories and categories.size() > 0">
<foreach collection="categories" item="categoryId" open="AND ( " separator=" OR " close=" )">
CATEGORY_ID = #{categoryId}
</foreach>
</if>
</select> </select>
<select id="selectCountByCustomerId" resultType="int"> <select id="selectCountByCustomerId" resultType="int">

Loading…
Cancel
Save