|  |  | @ -29,6 +29,9 @@ import com.epmet.dao.IssueProjectTagDictDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.IssueTagsDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.IssueTagsDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.AddTagFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.IssueTagFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.IssueTagsFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.IssueTagsSaveFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.AddTagResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.IssueCategoryTagResultDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.IssueProjectTagDictEntity; | 
			
		
	
	
		
			
				
					|  |  | @ -41,11 +44,14 @@ 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 org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import static java.util.stream.Collectors.toList; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * 议题关联标签表 | 
			
		
	
		
			
				
					|  |  |  |  * | 
			
		
	
	
		
			
				
					|  |  | @ -134,6 +140,7 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020/12/9 下午3:29 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public AddTagResultDTO addTag(AddTagFormDTO form, TokenDto tokenDto) { | 
			
		
	
		
			
				
					|  |  |  |         form.setCustomerId(tokenDto.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         String tagId = baseDao.selectTagNameCount(form); | 
			
		
	
	
		
			
				
					|  |  | @ -155,4 +162,66 @@ public class IssueTagsServiceImpl extends BaseServiceImpl<IssueTagsDao, IssueTag | 
			
		
	
		
			
				
					|  |  |  |         return new AddTagResultDTO(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * @Description  议题标签保存/修改 | 
			
		
	
		
			
				
					|  |  |  |      * @Param form | 
			
		
	
		
			
				
					|  |  |  |      * @Param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @author zxc | 
			
		
	
		
			
				
					|  |  |  |      * @date 2020/12/10 上午9:37 | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     @Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  |     public void issueTagSave(IssueTagsSaveFormDTO form, TokenDto tokenDto) { | 
			
		
	
		
			
				
					|  |  |  |         String customerId = tokenDto.getCustomerId(); | 
			
		
	
		
			
				
					|  |  |  |         List<IssueTagFormDTO> tags = baseDao.selectTagsByIssueId(form.getIssueId()); | 
			
		
	
		
			
				
					|  |  |  |         if (CollectionUtils.isEmpty(form.getTagList())){ | 
			
		
	
		
			
				
					|  |  |  |             // 清空此议题的标签
 | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(tags)){ | 
			
		
	
		
			
				
					|  |  |  |                 tags.forEach(t -> { | 
			
		
	
		
			
				
					|  |  |  |                     // 缓存标签 -1
 | 
			
		
	
		
			
				
					|  |  |  |                     dictRedis.editTagUseCount(customerId,t.getCategoryId(),t,NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |                 // 数据库有关标签使用次数 -1  0:+1 ; 1:-1;
 | 
			
		
	
		
			
				
					|  |  |  |                 issueProjectTagDictDao.updateTagsUseCount(tags,customerId,NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             // 删除数据库有关此议题标签
 | 
			
		
	
		
			
				
					|  |  |  |             baseDao.deleteTagsByIssueId(form.getIssueId()); | 
			
		
	
		
			
				
					|  |  |  |             return; | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         List<IssueTagFormDTO> selectTags = form.getTagList(); | 
			
		
	
		
			
				
					|  |  |  |         List<IssueTagFormDTO> newTags = issueProjectTagDictDao.selectTagId(selectTags, customerId); | 
			
		
	
		
			
				
					|  |  |  |         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); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |                 // 数据库有关标签使用次数 -1  0:+1 ; 1:-1;
 | 
			
		
	
		
			
				
					|  |  |  |                 issueProjectTagDictDao.updateTagsUseCount(delList,customerId,NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             // 需要新增的标签
 | 
			
		
	
		
			
				
					|  |  |  |             List<IssueTagFormDTO> addList = newTags.stream().filter(tag -> !tags.contains(tag)).collect(toList()); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(addList)){ | 
			
		
	
		
			
				
					|  |  |  |                 addList.forEach(a -> { | 
			
		
	
		
			
				
					|  |  |  |                     // 缓存标签+1
 | 
			
		
	
		
			
				
					|  |  |  |                     dictRedis.editTagUseCount(customerId,a.getCategoryId(),a,NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |                 }); | 
			
		
	
		
			
				
					|  |  |  |                 // 数据库对应标签 议题使用次数 +1
 | 
			
		
	
		
			
				
					|  |  |  |                 issueProjectTagDictDao.updateTagsUseCount(addList,customerId,NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             // 删除数据库有关此议题标签
 | 
			
		
	
		
			
				
					|  |  |  |             baseDao.deleteTagsByIssueId(form.getIssueId()); | 
			
		
	
		
			
				
					|  |  |  |             // 新增最新议题标签
 | 
			
		
	
		
			
				
					|  |  |  |             List<IssueTagsFormDTO> needInsert = ConvertUtils.sourceToTarget(newTags, IssueTagsFormDTO.class); | 
			
		
	
		
			
				
					|  |  |  |             needInsert.forEach(n -> { | 
			
		
	
		
			
				
					|  |  |  |                 n.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |                 n.setGridId(issueTagsDTO.getGridId()); | 
			
		
	
		
			
				
					|  |  |  |                 n.setIssueId(form.getIssueId()); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |             baseDao.insertNewTags(needInsert); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |