|  |  | @ -1435,7 +1435,13 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit | 
			
		
	
		
			
				
					|  |  |  | 			e.setArticleId(articleId); | 
			
		
	
		
			
				
					|  |  |  | 			articleTags.add(e); | 
			
		
	
		
			
				
					|  |  |  | 		}); | 
			
		
	
		
			
				
					|  |  |  | 		articleTagsService.insertBatch(articleTags); | 
			
		
	
		
			
				
					|  |  |  | 		if(!CollectionUtils.isEmpty(articleTags)){ | 
			
		
	
		
			
				
					|  |  |  | 			LambdaQueryWrapper<ArticleTagsEntity> queryWrapper=new LambdaQueryWrapper(); | 
			
		
	
		
			
				
					|  |  |  | 			queryWrapper.eq(ArticleTagsEntity::getCustomerId,customerId) | 
			
		
	
		
			
				
					|  |  |  | 					.eq(ArticleTagsEntity::getArticleId,articleId); | 
			
		
	
		
			
				
					|  |  |  | 			articleTagsDao.delete(queryWrapper); | 
			
		
	
		
			
				
					|  |  |  | 			articleTagsService.insertBatch(articleTags); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
	
		
			
				
					|  |  | @ -1543,7 +1549,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit | 
			
		
	
		
			
				
					|  |  |  | 			articleContent.setArticleId(article.getId()); | 
			
		
	
		
			
				
					|  |  |  | 			articleContent.setContent(formDTO.getContent()); | 
			
		
	
		
			
				
					|  |  |  | 			articleContent.setContentType("rich_text"); | 
			
		
	
		
			
				
					|  |  |  | 			articleContent.setOrderNum(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  | 			articleContent.setOrderNum(NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  | 			articleContentDao.insert(articleContent); | 
			
		
	
		
			
				
					|  |  |  | 			// 3.操作记录
 | 
			
		
	
		
			
				
					|  |  |  | 			ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity(); | 
			
		
	
	
		
			
				
					|  |  | @ -1808,4 +1814,113 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit | 
			
		
	
		
			
				
					|  |  |  | 			baseDao.updateById(articleEntity); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * 修改文章 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param formDTO | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	@Transactional(rollbackFor = Exception.class) | 
			
		
	
		
			
				
					|  |  |  | 	@Override | 
			
		
	
		
			
				
					|  |  |  | 	public void updateArticle(UpdateArticleFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  | 		CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		if (null == agencyInfo){ | 
			
		
	
		
			
				
					|  |  |  | 			throw new EpmetException("未查询到组织信息:"+staffInfo.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		// 1.文章
 | 
			
		
	
		
			
				
					|  |  |  | 		ArticleEntity articleEntity = baseDao.selectById(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 		if (ArticleConstant.OFFLINE.equals(articleEntity.getStatusFlag())) { | 
			
		
	
		
			
				
					|  |  |  | 			throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已下线的文章不能编辑", "已下线的文章不能编辑"); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setPublishWay(ArticleConstant.PUBLISH_WAY_MANUAL); | 
			
		
	
		
			
				
					|  |  |  | 		if (formDTO.getPublisherType().equals(DraftConstant.GRID)){ | 
			
		
	
		
			
				
					|  |  |  | 			articleEntity.setGridId(formDTO.getPublisher()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setPreviewContent(getPreviewContent(formDTO.getContent()).length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? getPreviewContent(formDTO.getContent()).substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : getPreviewContent(formDTO.getContent())); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setPublishDate(DateUtils.stringToDate(formDTO.getPublishDate(),DateUtils.DATE_PATTERN)); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setPublisherId(formDTO.getPublisher()); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|"))); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setOrgId(staffInfo.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setOrgIdPath(StringUtils.isBlank(agencyInfo.getPids()) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId())); | 
			
		
	
		
			
				
					|  |  |  | 		articleEntity.setRichTextFlag(NumConstant.ONE_STR); | 
			
		
	
		
			
				
					|  |  |  | 		baseDao.updateById(articleEntity); | 
			
		
	
		
			
				
					|  |  |  | 		// 2.内容
 | 
			
		
	
		
			
				
					|  |  |  | 		ArticleContentEntity articleContent = articleContentDao.selectByArticleId(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 		articleContent.setContent(formDTO.getContent()); | 
			
		
	
		
			
				
					|  |  |  | 		articleContentDao.updateById(articleContent); | 
			
		
	
		
			
				
					|  |  |  | 		// 3.操作记录
 | 
			
		
	
		
			
				
					|  |  |  | 		ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity(); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setArticleId(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setGridIds(CollectionUtils.isEmpty(formDTO.getGridIdList()) ? "" : formDTO.getGridIdList().stream().collect(Collectors.joining(":"))); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setOpUser(staffInfo.getAgencyName().concat("-").concat(staffInfo.getRealName())); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setContent(articleOperateRecord.getOpUser() + "发布文章【" +formDTO.getTitle() + "】"); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setOpType(ArticleConstant.UPDATE_ARTICEL); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecord.setOpTime(new Date()); | 
			
		
	
		
			
				
					|  |  |  | 		articleOperateRecordService.insert(articleOperateRecord); | 
			
		
	
		
			
				
					|  |  |  | 		// 4.发布范围
 | 
			
		
	
		
			
				
					|  |  |  | 		if (!CollectionUtils.isEmpty(formDTO.getGridIdList())){ | 
			
		
	
		
			
				
					|  |  |  | 			List<ArticlePublishRangeEntity> rangeList = new ArrayList<>(); | 
			
		
	
		
			
				
					|  |  |  | 			formDTO.getGridIdList().forEach(g -> { | 
			
		
	
		
			
				
					|  |  |  | 				GridInfoCache gridInfoCache = CustomerOrgRedis.getGridInfo(g); | 
			
		
	
		
			
				
					|  |  |  | 				if (null == gridInfoCache){ | 
			
		
	
		
			
				
					|  |  |  | 					throw new EpmetException("未查询到网格信息:"+g); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  | 				ArticlePublishRangeEntity articlePublishRange = ConvertUtils.sourceToTarget(gridInfoCache,ArticlePublishRangeEntity.class); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setArticleId(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setGridId(g); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setAgencyGridName(gridInfoCache.getGridNamePath()); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setAgencyId(gridInfoCache.getPid()); | 
			
		
	
		
			
				
					|  |  |  | 				AgencyInfoCache agencyInfoCache = CustomerOrgRedis.getAgencyInfo(gridInfoCache.getPid()); | 
			
		
	
		
			
				
					|  |  |  | 				if (null == agencyInfoCache){ | 
			
		
	
		
			
				
					|  |  |  | 					throw new EpmetException("未查询到组织信息:"+gridInfoCache.getPid()); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setPids(agencyInfoCache.getPids()); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setPublishStatus(ArticleConstant.PUBLISHED); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRange.setId(null); | 
			
		
	
		
			
				
					|  |  |  | 				rangeList.add(articlePublishRange); | 
			
		
	
		
			
				
					|  |  |  | 			}); | 
			
		
	
		
			
				
					|  |  |  | 			if(org.apache.commons.collections4.CollectionUtils.isNotEmpty(rangeList)){ | 
			
		
	
		
			
				
					|  |  |  | 				//先删除,后插入
 | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRangeDao.deleteByArticleId(formDTO.getArticleId(),formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 				articlePublishRangeService.insertBatch(rangeList); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		// 5.文章标签
 | 
			
		
	
		
			
				
					|  |  |  | 		UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = updateCustomerTagV2(formDTO.getUserId(), formDTO.getCustomerId(), StringUtils.isBlank(articleEntity.getTags()) ? "" : articleEntity.getTags()); | 
			
		
	
		
			
				
					|  |  |  | 		if (null != updateCustomerTagCacheDTO){ | 
			
		
	
		
			
				
					|  |  |  | 			addArticleTagsV2(updateCustomerTagCacheDTO,formDTO.getCustomerId(),articleEntity.getId()); | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		// 6.更新网格tag
 | 
			
		
	
		
			
				
					|  |  |  | 		List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = updateGridTagV2(updateCustomerTagCacheDTO, formDTO.getCustomerId(), formDTO.getGridIdList(), formDTO.getUserId()); | 
			
		
	
		
			
				
					|  |  |  | 		// 7.文章封面
 | 
			
		
	
		
			
				
					|  |  |  | 		if (StringUtils.isNotBlank(formDTO.getImgUrl())){ | 
			
		
	
		
			
				
					|  |  |  | 			ArticleCoverEntity articleCoverEntity = articleCoverDao.selectByArticleId(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 			if (null != articleCoverEntity) { | 
			
		
	
		
			
				
					|  |  |  | 				articleCoverEntity.setImgUrl(formDTO.getImgUrl()); | 
			
		
	
		
			
				
					|  |  |  | 				articleCoverEntity.setAuditStatus("pass"); | 
			
		
	
		
			
				
					|  |  |  | 				articleCoverDao.updateById(articleCoverEntity); | 
			
		
	
		
			
				
					|  |  |  | 			}else{ | 
			
		
	
		
			
				
					|  |  |  | 				ArticleCoverEntity articleCover = new ArticleCoverEntity(); | 
			
		
	
		
			
				
					|  |  |  | 				articleCover.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 				articleCover.setArticleId(formDTO.getArticleId()); | 
			
		
	
		
			
				
					|  |  |  | 				articleCover.setImgUrl(formDTO.getImgUrl()); | 
			
		
	
		
			
				
					|  |  |  | 				articleCover.setAuditStatus("pass"); | 
			
		
	
		
			
				
					|  |  |  | 				articleCoverDao.insert(articleCover); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		// 8.更新redis
 | 
			
		
	
		
			
				
					|  |  |  | 		try { | 
			
		
	
		
			
				
					|  |  |  | 			this.updateCacheCustomerTag(updateCustomerTagCacheDTO); | 
			
		
	
		
			
				
					|  |  |  | 			this.updateCacheGridTag(updateGridTagCacheDTOS); | 
			
		
	
		
			
				
					|  |  |  | 		} catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  | 			//我觉着没必要抛出异常吧,日志打印一下吧
 | 
			
		
	
		
			
				
					|  |  |  | 			log.warn("scanAllPassPublishArticle update redis exception", e); | 
			
		
	
		
			
				
					|  |  |  | 			// throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg());
 | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |