From 99edea7a2b3605a3feecb73e61a094faf5abee9a Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 15 Jun 2020 09:31:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ArticleServiceImpl.java | 388 +++++++++--------- 1 file changed, 195 insertions(+), 193 deletions(-) diff --git a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java index e6132615c1..2b2005512f 100644 --- a/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java +++ b/epmet-module/gov-voice/gov-voice-server/src/main/java/com/epmet/service/impl/ArticleServiceImpl.java @@ -56,7 +56,6 @@ import com.epmet.service.*; import com.epmet.utils.ModuleConstant; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; -import com.sun.javafx.binding.StringConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.jsoup.helper.StringUtil; @@ -68,7 +67,6 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import javax.swing.text.StringContent; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -136,8 +134,8 @@ public class ArticleServiceImpl extends BaseServiceImpl result = govOrgOpenFeignClient.getAgencyGridList(tokenDTO.getUserId()); - if(!result.success()){ + if (!result.success()) { throw new RenException(result.getInternalMsg()); } return result.getData(); } - /** - * @param tokenDTO - * @return - * @Author sun - * @Description 党建声音-政府端-可选发布单位 - **/ - @Override - public PublishAgencyListResultDTO publishAgencyList(TokenDto tokenDTO) { - Result result = govOrgOpenFeignClient.getPublishAgencyList(tokenDTO.getUserId()); - if(!result.success()){ + /** + * @param tokenDTO + * @return + * @Author sun + * @Description 党建声音-政府端-可选发布单位 + **/ + @Override + public PublishAgencyListResultDTO publishAgencyList(TokenDto tokenDTO) { + Result result = govOrgOpenFeignClient.getPublishAgencyList(tokenDTO.getUserId()); + if (!result.success()) { throw new RenException(result.getInternalMsg()); } - return result.getData(); - } + return result.getData(); + } @Override @Transactional(rollbackFor = Exception.class) @@ -222,10 +220,10 @@ public class ArticleServiceImpl extends BaseServiceImpl articleContentList = baseDao.queryGovArticleContent(articleId); - if(null!=articleContentList&&articleContentList.size()>0){ + if (null != articleContentList && articleContentList.size() > 0) { articleDetail.setArticleContentList(articleContentList); - }else{ + } else { articleDetail.setArticleContentList(new ArrayList<>()); } - if (StringUtils.isNoneBlank(articleDetail.getTags())) { - String[] tagNames = articleDetail.getTags().split("\\|"); - articleDetail.setTagNameList(tagNames); - }else{ + if (StringUtils.isNoneBlank(articleDetail.getTags())) { + String[] tagNames = articleDetail.getTags().split("\\|"); + articleDetail.setTagNameList(tagNames); + } else { articleDetail.setTagNameList(new String[0]); } - ArticleEntity articleEntity=this.baseDao.selectById(articleId); + ArticleEntity articleEntity = this.baseDao.selectById(articleId); log.info(String.format("当前文章id%s,发布人id%s,当前用户id%s", articleId, articleEntity.getCreatedBy(), loginUserUtil.getLoginUserId())); - if(articleEntity.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + if (articleEntity.getCreatedBy().equals(loginUserUtil.getLoginUserId())) { articleDetail.setIsMePublished(true); - }else{ + } else { articleDetail.setIsMePublished(false); } } @@ -268,7 +266,7 @@ public class ArticleServiceImpl extends BaseServiceImpl publishRangeEntityList = buildDraftPublishRange(draftEntity,tokenDto, fromDTO); + List publishRangeEntityList = buildDraftPublishRange(draftEntity, tokenDto, fromDTO); executeSaveDraftAttr(draftEntity, coverEntity, publishRangeEntityList); @@ -309,16 +307,16 @@ public class ArticleServiceImpl extends BaseServiceImpl publishRangeEntityList) { - Map draftIdMap = new HashMap<>(); + Map draftIdMap = new HashMap<>(); //物理删除 draftCoverDao.deleteByDraftId(draftEntity.getId()); - if (coverEntity != null){ + if (coverEntity != null) { draftCoverDao.insert(coverEntity); } //物理删除 draftPublishRangeDao.deleteByDraftId(draftEntity.getId()); - if (!CollectionUtils.isEmpty(publishRangeEntityList)){ - publishRangeEntityList.forEach(publishRange->draftPublishRangeDao.insert(publishRange)); + if (!CollectionUtils.isEmpty(publishRangeEntityList)) { + publishRangeEntityList.forEach(publishRange -> draftPublishRangeDao.insert(publishRange)); } draftDao.updateById(draftEntity); } private List buildDraftPublishRange(DraftEntity draftEntity, TokenDto tokenDto, DraftAttrFromDTO fromDTO) { - if (CollectionUtils.isEmpty(fromDTO.getGridIdList())){ - return null; - } + if (CollectionUtils.isEmpty(fromDTO.getGridIdList())) { + return null; + } List publishRangeEntityList = new ArrayList<>(); List agencyGridNameList = new ArrayList<>(); @@ -386,15 +384,15 @@ public class ArticleServiceImpl extends BaseServiceImpl agencyGridNameList, List publishRangeEntityList, DraftAttrFromDTO fromDTO, ArticleGridResultDTO articleGridResultDTO) { articleGridResultDTO.getSubAgencyGridList().forEach(subAgencyGrid -> { - buildName(tokenDto,agencyGridNameList, publishRangeEntityList,fromDTO, subAgencyGrid); + buildName(tokenDto, agencyGridNameList, publishRangeEntityList, fromDTO, subAgencyGrid); }); if (!CollectionUtils.isEmpty(articleGridResultDTO.getSubAgencyGridList())) { articleGridResultDTO.getSubAgencyGridList().forEach(subAgencyGrid -> { @@ -422,7 +420,7 @@ public class ArticleServiceImpl extends BaseServiceImpl agencyGridNameList, List publishRangeEntityList, DraftAttrFromDTO fromDTO, ArticleGridResultDTO articleGridResultDTO) { List gridIdList = fromDTO.getGridIdList(); List gridList = articleGridResultDTO.getGridList(); - if (!CollectionUtils.isEmpty(gridList)&&!CollectionUtils.isEmpty(gridIdList)) { + if (!CollectionUtils.isEmpty(gridList) && !CollectionUtils.isEmpty(gridIdList)) { gridList.forEach(grid -> { if (gridIdList.contains(grid.getGridId())) { String agencyGridName = articleGridResultDTO.getAgencyName().concat(StrConstant.HYPHEN).concat(grid.getGridName()); @@ -483,14 +481,14 @@ public class ArticleServiceImpl extends BaseServiceImpl { - offLineRangeDesc.append(offLineRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : ""); - offLineRangeDesc.append(off.getAgencyGridName()); - }); - content = String.format(ArticleConstant.OFF_LINE_ARTICLE_MSG, articleEntity.getPublisherName(), staffDTO.getRealName(), articleEntity.getTitle(), offLineRangeDesc); - } - recordEntity.setContent(content); + //下线文案,分为全部下线和部分下线 + String content = ""; + if (null == publishedList || publishedList.size() < NumConstant.ONE) { + content = String.format(ArticleConstant.OFF_LINE_ALL_ARTICLE_MSG, articleEntity.getPublisherName(), staffDTO.getRealName(), articleEntity.getTitle()); + } else { + StringBuffer offLineRangeDesc = new StringBuffer(); + offLineList.forEach(off -> { + offLineRangeDesc.append(offLineRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : ""); + offLineRangeDesc.append(off.getAgencyGridName()); + }); + content = String.format(ArticleConstant.OFF_LINE_ARTICLE_MSG, articleEntity.getPublisherName(), staffDTO.getRealName(), articleEntity.getTitle(), offLineRangeDesc); + } + recordEntity.setContent(content); recordEntity.setOpType(ArticleConstant.OFFLINE); recordEntity.setOpTime(date); articleOperateRecordService.insert(recordEntity); @@ -582,7 +580,7 @@ public class ArticleServiceImpl extends BaseServiceImpl resultList; List roles = epmetUserOpenFeignClient.getStaffRoles(tokenDto.getUserId()).getData(); LoginUserDetailsFormDTO loginUserDetailsFormDTO = new LoginUserDetailsFormDTO(); @@ -616,7 +614,7 @@ public class ArticleServiceImpl extends BaseServiceImpl { String tags = result.getTags(); List tagList = new ArrayList<>(); - tagList= Arrays.asList(tags.split("[|]")); + tagList = Arrays.asList(tags.split("[|]")); result.setTagNameList(tagList); }); PageInfo pageInfo = new PageInfo<>(resultList); @@ -625,7 +623,7 @@ public class ArticleServiceImpl extends BaseServiceImpl(resultList, pageInfo.getTotal()); } - /** - * @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播 - * @param commonArticleListFormDTO :: getGridId :: getNum - * @return List - * @author wangc - * @date 2020.06.02 16:13 - **/ - @Override - public List getTopArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { - return baseDao.selectTopArticleMsg(commonArticleListFormDTO.getGridId(), - null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ? - NumConstant.THREE : commonArticleListFormDTO.getNum()); - } - - /** - * @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端首页最新文章列表 - * @param commonArticleListFormDTO :: getGridId :: getNum - * @return List - * @author wangc - * @date 2020.06.03 09:53 - **/ - @Override - public List getLatestArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { - return baseDao.selectLatestArticleMsg(commonArticleListFormDTO.getGridId(), - null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ? - NumConstant.FIVE : commonArticleListFormDTO.getNum()); - } - - /** - * @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表 - * @param articlePageFormDTO - * @return List - * @author wangc - * @date 2020.06.03 14:19 - **/ - @Override - public List getArticleList(ArticlePageFormDTO articlePageFormDTO) { - PageHelper.startPage(articlePageFormDTO.getPageNo(),articlePageFormDTO.getPageSize()); - return baseDao.selectArticleList(articlePageFormDTO.getGridId(),articlePageFormDTO.getTagIdList()); - } + /** + * @param commonArticleListFormDTO :: getGridId :: getNum + * @return List + * @Description 根据网格Id查找置顶文章的相关信息列表 用处:居民端首页轮播 + * @author wangc + * @date 2020.06.02 16:13 + **/ + @Override + public List getTopArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { + return baseDao.selectTopArticleMsg(commonArticleListFormDTO.getGridId(), + null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ? + NumConstant.THREE : commonArticleListFormDTO.getNum()); + } + + /** + * @param commonArticleListFormDTO :: getGridId :: getNum + * @return List + * @Description 根据网格Id查找最新文章的相关信息列表 用处:居民端首页最新文章列表 + * @author wangc + * @date 2020.06.03 09:53 + **/ + @Override + public List getLatestArticleList(CommonArticleListFormDTO commonArticleListFormDTO) { + return baseDao.selectLatestArticleMsg(commonArticleListFormDTO.getGridId(), + null == commonArticleListFormDTO.getNum() || commonArticleListFormDTO.getNum() <= NumConstant.ZERO ? + NumConstant.FIVE : commonArticleListFormDTO.getNum()); + } + + /** + * @param articlePageFormDTO + * @return List + * @Description 根据网格Id和标签列表查找文章的相关信息列表 用处:居民端党建声音列表 + * @author wangc + * @date 2020.06.03 14:19 + **/ + @Override + public List getArticleList(ArticlePageFormDTO articlePageFormDTO) { + PageHelper.startPage(articlePageFormDTO.getPageNo(), articlePageFormDTO.getPageSize()); + return baseDao.selectArticleList(articlePageFormDTO.getGridId(), articlePageFormDTO.getTagIdList()); + } /** * @param formDTO @@ -700,7 +698,7 @@ public class ArticleServiceImpl extends BaseServiceImpl resultDTOResult = epmetUserOpenFeignClient.getLoginUserDetails(loginUserDetailsFormDTO); - String agencyId = resultDTOResult.getData().getOrgIdPath().substring(resultDTOResult.getData().getOrgIdPath().lastIndexOf(":")+NumConstant.ONE); + String agencyId = resultDTOResult.getData().getOrgIdPath().substring(resultDTOResult.getData().getOrgIdPath().lastIndexOf(":") + NumConstant.ONE); //存放树的每一个节点对象,用于将同一节点下的网格列表合并(主键:agencyId 值:节点对象) Map map = new HashMap<>(); //3:循环可下线网格列表,根据pids组织每一个树节点对象信息 @@ -753,6 +751,7 @@ public class ArticleServiceImpl extends BaseServiceImpl list = agencyGridListToTree(resultDTOList); return list.get(NumConstant.ZERO); } + /** * @Author sun * @Description 可下线网格列表-将list转为Tree结构 @@ -790,6 +789,7 @@ public class ArticleServiceImpl extends BaseServiceImpl params = new HashMap<>(); - params.put(ModuleConstant.FIELD_GRID_ID_CAMEL,articleDetailFormDTO.getGridId()); - params.put(ModuleConstant.FIELD_USER_ID_CAMEL,articleDetailFormDTO.getUserId()); - params.put(ModuleConstant.FIELD_ARTICLE_ID_CAMEL,articleDetailFormDTO.getArticleId()); - params.put(ModuleConstant.FIELD_CUSTOMER_ID_CAMEL,articleInfo.getCustomerId()); - params.put(FieldConstant.DEL_FLAG_HUMP,NumConstant.ZERO_STR); + Map params = new HashMap<>(); + params.put(ModuleConstant.FIELD_GRID_ID_CAMEL, articleDetailFormDTO.getGridId()); + params.put(ModuleConstant.FIELD_USER_ID_CAMEL, articleDetailFormDTO.getUserId()); + params.put(ModuleConstant.FIELD_ARTICLE_ID_CAMEL, articleDetailFormDTO.getArticleId()); + params.put(ModuleConstant.FIELD_CUSTOMER_ID_CAMEL, articleInfo.getCustomerId()); + params.put(FieldConstant.DEL_FLAG_HUMP, NumConstant.ZERO_STR); List existedVisitRecord = articleVisitRecordService.list(params); //3.没有则插入 - if(null == existedVisitRecord || existedVisitRecord.size() < NumConstant.ONE){ + if (null == existedVisitRecord || existedVisitRecord.size() < NumConstant.ONE) { ArticleVisitRecordEntity recordToInsert = new ArticleVisitRecordEntity(); recordToInsert.setArticleId(articleDetailFormDTO.getArticleId()); recordToInsert.setGridId(articleDetailFormDTO.getGridId()); @@ -856,9 +856,9 @@ public class ArticleServiceImpl extends BaseServiceImpl draftContents = draftContentDao.selectByDraftId(draftId,null); - DraftCoverEntity draftCover = draftCoverDao.selectByDraftId(draftId,null); + List draftContents = draftContentDao.selectByDraftId(draftId, null); + DraftCoverEntity draftCover = draftCoverDao.selectByDraftId(draftId, null); List draftPublishRange = draftPublishRangeDao.selectByDraftId(draftId); //3.生成文章以及相关记录 - ArticleEntity article = ConvertUtils.sourceToTarget(draft,ArticleEntity.class); + ArticleEntity article = ConvertUtils.sourceToTarget(draft, ArticleEntity.class); article.setId(null); article.setDraftId(draftId); article.setStatusFlag(DraftConstant.PUBLISHED); baseDao.insert(article); - if(null != draftContents && draftContents.size() > NumConstant.ZERO){ + if (null != draftContents && draftContents.size() > NumConstant.ZERO) { draftContents.forEach(content -> { content.setOrderNum(content.getOrderNum()); - ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content,ArticleContentEntity.class); + ArticleContentEntity contentToInsert = ConvertUtils.sourceToTarget(content, ArticleContentEntity.class); contentToInsert.setArticleId(article.getId()); contentToInsert.setId(null); articleContentDao.insert(contentToInsert); }); } - if(null != draftPublishRange && draftPublishRange.size() > NumConstant.ZERO){ + if (null != draftPublishRange && draftPublishRange.size() > NumConstant.ZERO) { draftPublishRange.forEach(range -> { range.setPublishStatus(DraftConstant.PUBLISHED); - ArticlePublishRangeEntity rangeToInsert = ConvertUtils.sourceToTarget(range,ArticlePublishRangeEntity.class); + ArticlePublishRangeEntity rangeToInsert = ConvertUtils.sourceToTarget(range, ArticlePublishRangeEntity.class); rangeToInsert.setArticleId(article.getId()); rangeToInsert.setId(null); articlePublishRangeDao.insert(rangeToInsert); draftPublishRangeDao.updateById(range); }); - if(null != draftCover){ - ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover,ArticleCoverEntity.class); + if (null != draftCover) { + ArticleCoverEntity coverToInsert = ConvertUtils.sourceToTarget(draftCover, ArticleCoverEntity.class); coverToInsert.setArticleId(article.getId()); coverToInsert.setId(null); articleCoverDao.insert(coverToInsert); @@ -920,7 +920,7 @@ public class ArticleServiceImpl extends BaseServiceImpl imgSyncScanResult = null; Result textSyncScanResult = null; - if(!CollectionUtils.isEmpty(imgScanParamDTO.getTasks())){ - log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO)); + if (!CollectionUtils.isEmpty(imgScanParamDTO.getTasks())) { + log.info("scanContent imgScanParamDTO:{}", JSON.toJSONString(imgScanParamDTO)); imgSyncScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); log.info("scanContent imgSyncScanResult:{}", JSON.toJSONString(imgSyncScanResult)); } - if(!CollectionUtils.isEmpty(textScanParamDTO.getTasks())){ - log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO)); + if (!CollectionUtils.isEmpty(textScanParamDTO.getTasks())) { + log.info("scanContent textScanParamDTO:{}", JSON.toJSONString(textScanParamDTO)); textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); log.info("scanContent textSyncScanResult:{}", JSON.toJSONString(textSyncScanResult)); } result = new SyncScanResult(); - if (imgSyncScanResult != null){ + if (imgSyncScanResult != null) { SyncScanResult imgSyncScanResultData = imgSyncScanResult.getData(); if (imgSyncScanResult.success()) { result.setAllPass(imgSyncScanResultData.isAllPass()); @@ -1008,15 +1008,16 @@ public class ArticleServiceImpl extends BaseServiceImpl updateGridTagCacheDTOS = this.updateGridTag(tokenDto, draftId, updateCustomerTagCacheDTO); @@ -1044,31 +1045,31 @@ public class ArticleServiceImpl extends BaseServiceImpl failDataIds = syncScanResult.getFailDataIds(); - for(String id:failDataIds) { + for (String id : failDataIds) { if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX) >= NumConstant.ZERO) { - draftCoverDao.updateAuditStatusById(id.replace(ModuleConstant.SCAN_COVER_PREFIX.concat(StrConstant.UNDER_LINE),""), ModuleConstant.AUDIT_STATUS_FAIL); + draftCoverDao.updateAuditStatusById(id.replace(ModuleConstant.SCAN_COVER_PREFIX.concat(StrConstant.UNDER_LINE), ""), ModuleConstant.AUDIT_STATUS_FAIL); coverFail = true; } else { draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_FAIL); @@ -1078,21 +1079,22 @@ public class ArticleServiceImpl extends BaseServiceImpl successDataIds = syncScanResult.getSuccessDataIds(); successDataIds.forEach(id -> { if (id.indexOf(ModuleConstant.SCAN_COVER_PREFIX) >= NumConstant.ZERO) { - draftCoverDao.updateAuditStatusById(id.replace(ModuleConstant.SCAN_COVER_PREFIX.concat(StrConstant.UNDER_LINE),""), ModuleConstant.AUDIT_STATUS_PASS); + draftCoverDao.updateAuditStatusById(id.replace(ModuleConstant.SCAN_COVER_PREFIX.concat(StrConstant.UNDER_LINE), ""), ModuleConstant.AUDIT_STATUS_PASS); } else { draftContentDao.updateAuditStatusById(id, ModuleConstant.AUDIT_STATUS_PASS); } }); - if (coverFail || contentFail){ + if (coverFail || contentFail) { String auditMsg = ""; - if (coverFail&&contentFail){ + if (coverFail && contentFail) { auditMsg = ModuleConstant.DRAFT_CONTENT_AND_COVER; - }else if (contentFail){ + } else if (contentFail) { auditMsg = ModuleConstant.DRAFT_CONTENT; - }else if (coverFail){ - auditMsg = ModuleConstant.DRAFT_COVER;; + } else if (coverFail) { + auditMsg = ModuleConstant.DRAFT_COVER; + ; } - this.sendMsg(draft.getCustomerId(), draft.getTitle(), String.format(ModuleConstant.MSG_AUDIT_CONTENT, draft.getTitle(),auditMsg)); + this.sendMsg(draft.getCustomerId(), draft.getTitle(), String.format(ModuleConstant.MSG_AUDIT_CONTENT, draft.getTitle(), auditMsg)); } } catch (Exception e) { log.error("scanAllPassPublishArticle update db exception", e); @@ -1107,37 +1109,37 @@ public class ArticleServiceImpl extends BaseServiceImpl tagsList = Arrays.asList(tags.split("\\|")); List tagsInfo = new ArrayList<>(); @@ -1155,37 +1157,37 @@ public class ArticleServiceImpl extends BaseServiceImpl tagsInfo = formDto.getTagsInfo(); String customerId = formDto.getCustomerId(); //更新缓存标签使用数量 tagsInfo.forEach(resultDTO -> { - String customerKey = TagConstant.GOV_TAG_KEY+customerId; - tagRedis.updateTagUseCounts(customerKey,resultDTO); + String customerKey = TagConstant.GOV_TAG_KEY + customerId; + tagRedis.updateTagUseCounts(customerKey, resultDTO); }); //政府端更新redis的级联标签(set) List tagsInfoCopy = new ArrayList<>(); for (int i = 0; i < tagsInfo.size(); i++) { tagsInfoCopy.addAll(tagsInfo); - String key = TagConstant.GOV_RETAG_KEY+customerId+TagConstant.COLON+tagsInfo.get(i).getTagId(); + String key = TagConstant.GOV_RETAG_KEY + customerId + TagConstant.COLON + tagsInfo.get(i).getTagId(); tagsInfoCopy.remove(tagsInfo.get(i)); Set setTag = new HashSet<>(tagsInfoCopy); - tagRedis.updateMoreTag(key,setTag); + tagRedis.updateMoreTag(key, setTag); tagsInfoCopy.clear(); } } /** - * @Description 更新数据库 网格下的标签使用数量 居民端 * @param draftId * @param formDto + * @Description 更新数据库 网格下的标签使用数量 居民端 * @author zxc */ - public List updateGridTag(TokenDto tokenDto,String draftId,UpdateCustomerTagCacheDTO formDto){ + public List updateGridTag(TokenDto tokenDto, String draftId, UpdateCustomerTagCacheDTO formDto) { //获取草稿基本信息 DraftDTO draft = draftService.get(draftId); String customerId = draft.getCustomerId(); @@ -1193,7 +1195,7 @@ public class ArticleServiceImpl extends BaseServiceImpl gridIds = draftPublishRangeDao.selectGridIdByDraftId(draftId); - if (gridIds.size() == NumConstant.ZERO){ + if (gridIds.size() == NumConstant.ZERO) { throw new RenException(TagConstant.SELECT_GRIDIDLIST_FAILURE); } List gridTags = new ArrayList<>(); @@ -1205,7 +1207,7 @@ public class ArticleServiceImpl extends BaseServiceImpl { UpdateGridTagsFormDTO tag = new UpdateGridTagsFormDTO(); - BeanUtils.copyProperties(resultDTO,tag); + BeanUtils.copyProperties(resultDTO, tag); tag.setCreatedBy(userId); tag.setUpdatedBy(userId); tag.setCustomerId(customerId); @@ -1213,43 +1215,43 @@ public class ArticleServiceImpl extends BaseServiceImpl gridTagCache){ + public void updateCacheGridTag(List gridTagCache) { //更新 网格下 标签使用数量 List gridTagCacheCopy = new ArrayList<>(); gridTagCache.forEach(cacheDTO -> { String gridId = cacheDTO.getGridId(); - String key = TagConstant.GRID_TAG_KEY+gridId; + String key = TagConstant.GRID_TAG_KEY + gridId; List tagsInfo = cacheDTO.getTagsInfo(); tagsInfo.forEach(resultDTO -> { - tagRedis.updateTagUseCounts(key,resultDTO); + tagRedis.updateTagUseCounts(key, resultDTO); }); //级联 for (int i = 0; i < tagsInfo.size(); i++) { gridTagCacheCopy.addAll(tagsInfo); - String moreKey = TagConstant.GRID_RETAG_KEY+gridId+TagConstant.COLON+tagsInfo.get(i).getTagId(); + String moreKey = TagConstant.GRID_RETAG_KEY + gridId + TagConstant.COLON + tagsInfo.get(i).getTagId(); gridTagCacheCopy.remove(tagsInfo.get(i)); Set setTag = new HashSet<>(gridTagCacheCopy); - tagRedis.updateMoreTag(moreKey,setTag); + tagRedis.updateMoreTag(moreKey, setTag); gridTagCacheCopy.clear(); } }); } /** - * @Description 给文章挂标签 article_tags * @param formDto + * @Description 给文章挂标签 article_tags * @author zxc */ - public void addArticleTags(UpdateCustomerTagCacheDTO formDto,String draftId,TokenDto tokenDto){ + public void addArticleTags(UpdateCustomerTagCacheDTO formDto, String draftId, TokenDto tokenDto) { List addArticleTags = new ArrayList<>(); List tagsInfo = formDto.getTagsInfo(); DraftDTO draft = draftService.get(draftId); @@ -1262,7 +1264,7 @@ public class ArticleServiceImpl extends BaseServiceImpl