|
@ -30,6 +30,10 @@ import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
import com.epmet.commons.tools.redis.RedisKeys; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
@ -126,6 +130,8 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
private ArticleTagsDao articleTagsDao; |
|
|
private ArticleTagsDao articleTagsDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ArticleTagsService articleTagsService; |
|
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
@Value("${openapi.scan.server.url}") |
|
|
private String scanApiUrl; |
|
|
private String scanApiUrl; |
|
@ -1262,9 +1268,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
public UpdateCustomerTagCacheDTO updateCustomerTag(TokenDto tokenDto, String draftId) { |
|
|
public UpdateCustomerTagCacheDTO updateCustomerTag(TokenDto tokenDto, String draftId) { |
|
|
//获取草稿基本信息
|
|
|
//获取草稿基本信息
|
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
String tags = draft.getTags(); |
|
|
return updateCustomerTagV2(tokenDto.getUserId(), draft.getCustomerId(), draft.getTags()); |
|
|
String customerId = draft.getCustomerId(); |
|
|
} |
|
|
String userId = tokenDto.getUserId(); |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Desc: |
|
|
|
|
|
* @param userId |
|
|
|
|
|
* @param customerId |
|
|
|
|
|
* @param tags eg: aa|bb|cc |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/6/30 16:14 |
|
|
|
|
|
*/ |
|
|
|
|
|
public UpdateCustomerTagCacheDTO updateCustomerTagV2(String userId,String customerId,String tags){ |
|
|
UpdateCustomerTagCacheDTO result = null; |
|
|
UpdateCustomerTagCacheDTO result = null; |
|
|
if (StringUtils.isNotBlank(tags)) { |
|
|
if (StringUtils.isNotBlank(tags)) { |
|
|
result = new UpdateCustomerTagCacheDTO(); |
|
|
result = new UpdateCustomerTagCacheDTO(); |
|
@ -1278,8 +1293,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
result.setCustomerId(customerId); |
|
|
result.setCustomerId(customerId); |
|
|
result.setTagsInfo(tagsInfo); |
|
|
result.setTagsInfo(tagsInfo); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -1318,13 +1331,17 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
//获取草稿基本信息
|
|
|
//获取草稿基本信息
|
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
String customerId = draft.getCustomerId(); |
|
|
String customerId = draft.getCustomerId(); |
|
|
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); |
|
|
|
|
|
String userId = tokenDto.getUserId(); |
|
|
String userId = tokenDto.getUserId(); |
|
|
//根据草稿id查询发布范围id集合
|
|
|
//根据草稿id查询发布范围id集合
|
|
|
List<String> gridIds = draftPublishRangeDao.selectGridIdByDraftId(draftId); |
|
|
List<String> gridIds = draftPublishRangeDao.selectGridIdByDraftId(draftId); |
|
|
if (gridIds.size() == NumConstant.ZERO) { |
|
|
if (gridIds.size() == NumConstant.ZERO) { |
|
|
throw new RenException(TagConstant.SELECT_GRIDIDLIST_FAILURE); |
|
|
throw new RenException(TagConstant.SELECT_GRIDIDLIST_FAILURE); |
|
|
} |
|
|
} |
|
|
|
|
|
return updateGridTagV2(formDto,customerId,gridIds,userId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public List<UpdateGridTagCacheDTO> updateGridTagV2(UpdateCustomerTagCacheDTO formDto,String customerId,List<String> gridIds,String userId){ |
|
|
|
|
|
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); |
|
|
List<UpdateGridTagsFormDTO> gridTags = new ArrayList<>(); |
|
|
List<UpdateGridTagsFormDTO> gridTags = new ArrayList<>(); |
|
|
List<UpdateGridTagCacheDTO> gridTagCache = new ArrayList<>(); |
|
|
List<UpdateGridTagCacheDTO> gridTagCache = new ArrayList<>(); |
|
|
gridIds.forEach(gridId -> { |
|
|
gridIds.forEach(gridId -> { |
|
@ -1380,23 +1397,22 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
*/ |
|
|
*/ |
|
|
public void addArticleTags(UpdateCustomerTagCacheDTO formDto, String draftId, TokenDto tokenDto, Date createdTime) { |
|
|
public void addArticleTags(UpdateCustomerTagCacheDTO formDto, String draftId, TokenDto tokenDto, Date createdTime) { |
|
|
List<AddArticleTagsFormDTO> addArticleTags = new ArrayList<>(); |
|
|
|
|
|
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); |
|
|
|
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
DraftDTO draft = draftService.get(draftId); |
|
|
String customerId = draft.getCustomerId(); |
|
|
String customerId = draft.getCustomerId(); |
|
|
String userId = tokenDto.getUserId(); |
|
|
|
|
|
String articleId = articleDao.getArticleIdByDraftId(draftId); |
|
|
String articleId = articleDao.getArticleIdByDraftId(draftId); |
|
|
|
|
|
addArticleTagsV2(formDto,customerId,articleId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void addArticleTagsV2(UpdateCustomerTagCacheDTO formDto,String customerId,String articleId){ |
|
|
|
|
|
List<ArticleTagsEntity> articleTags = new ArrayList<>(); |
|
|
|
|
|
List<UpdateTagUseCountsResultDTO> tagsInfo = formDto.getTagsInfo(); |
|
|
tagsInfo.forEach(resultDTO -> { |
|
|
tagsInfo.forEach(resultDTO -> { |
|
|
AddArticleTagsFormDTO addArticleTag = new AddArticleTagsFormDTO(); |
|
|
ArticleTagsEntity e = ConvertUtils.sourceToTarget(resultDTO, ArticleTagsEntity.class); |
|
|
addArticleTag.setCreatedBy(userId); |
|
|
e.setCustomerId(customerId); |
|
|
addArticleTag.setUpdatedBy(userId); |
|
|
e.setArticleId(articleId); |
|
|
addArticleTag.setCustomerId(customerId); |
|
|
articleTags.add(e); |
|
|
addArticleTag.setArticleId(articleId); |
|
|
|
|
|
BeanUtils.copyProperties(resultDTO, addArticleTag); |
|
|
|
|
|
addArticleTag.setCreatedTime(createdTime); |
|
|
|
|
|
addArticleTags.add(addArticleTag); |
|
|
|
|
|
}); |
|
|
}); |
|
|
articleTagsDao.addArticleTags(addArticleTags); |
|
|
articleTagsService.insertBatch(articleTags); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -1454,6 +1470,100 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
return baseDao.selectArticleListByTag(tagId, pageNo, pageSize); |
|
|
return baseDao.selectArticleListByTag(tagId, pageNo, pageSize); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Desc: 发布文章/存草稿 |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/6/30 14:03 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
|
public void addOrSaveDraft(AddOrSaveDraftFormDTO formDTO) { |
|
|
|
|
|
String customerId = formDTO.getCustomerId(); |
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, formDTO.getUserId()); |
|
|
|
|
|
if (null == staffInfo){ |
|
|
|
|
|
throw new EpmetException("未查询到当前工作人员信息:"+formDTO.getUserId()); |
|
|
|
|
|
} |
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfo.getAgencyId()); |
|
|
|
|
|
if (null == agencyInfo){ |
|
|
|
|
|
throw new EpmetException("未查询到组织信息:"+staffInfo.getAgencyId()); |
|
|
|
|
|
} |
|
|
|
|
|
// 发文章
|
|
|
|
|
|
if (formDTO.getType().equals(ArticleConstant.SAVE_TYPE_ARTICLE)){ |
|
|
|
|
|
// 1.文章
|
|
|
|
|
|
ArticleEntity article = ConvertUtils.sourceToTarget(formDTO, ArticleEntity.class); |
|
|
|
|
|
article.setCustomerId(customerId); |
|
|
|
|
|
// 按照之前逻辑存成客户ID
|
|
|
|
|
|
article.setDepartmentId(customerId); |
|
|
|
|
|
article.setStatusFlag(DraftConstant.PUBLISHED); |
|
|
|
|
|
article.setPublishWay(ArticleConstant.PUBLISH_WAY_MANUAL); |
|
|
|
|
|
if (formDTO.getPublisherType().equals(DraftConstant.GRID)){ |
|
|
|
|
|
article.setGridId(formDTO.getPublisher()); |
|
|
|
|
|
} |
|
|
|
|
|
article.setTitleAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT); |
|
|
|
|
|
article.setPreviewContent(formDTO.getContent().length() > DraftConstant.PREVIEW_CONTENT_MAX_LENGTH ? formDTO.getContent().substring(NumConstant.ZERO,DraftConstant.PREVIEW_CONTENT_MAX_LENGTH) : formDTO.getContent()); |
|
|
|
|
|
article.setPublisherId(formDTO.getPublisher()); |
|
|
|
|
|
article.setPublishRangeDesc(formDTO.getPublishRangeDesc().stream().collect(Collectors.joining("、"))); |
|
|
|
|
|
article.setTags(CollectionUtils.isEmpty(formDTO.getTagNameList()) ? "" : formDTO.getTagNameList().stream().collect(Collectors.joining("|"))); |
|
|
|
|
|
article.setOrgId(staffInfo.getAgencyId()); |
|
|
|
|
|
article.setOrgIdPath(StringUtils.isBlank(agencyInfo.getPids()) || agencyInfo.getPids().equals(NumConstant.ZERO_STR) ? agencyInfo.getId() : agencyInfo.getPids().concat(":").concat(agencyInfo.getId())); |
|
|
|
|
|
baseDao.insert(article); |
|
|
|
|
|
// 2.内容
|
|
|
|
|
|
ArticleContentEntity articleContent = ConvertUtils.sourceToTarget(article, ArticleContentEntity.class); |
|
|
|
|
|
articleContent.setCustomerId(customerId); |
|
|
|
|
|
articleContent.setArticleId(article.getId()); |
|
|
|
|
|
articleContent.setContent(formDTO.getContent()); |
|
|
|
|
|
articleContent.setContentType("rich_text"); |
|
|
|
|
|
articleContent.setAuditStatus(ArticleConstant.AUDIT_WAY_NO_AUDIT); |
|
|
|
|
|
articleContent.setOrderNum(NumConstant.ZERO); |
|
|
|
|
|
articleContentDao.insert(articleContent); |
|
|
|
|
|
// 3.操作记录
|
|
|
|
|
|
ArticleOperateRecordEntity articleOperateRecord = new ArticleOperateRecordEntity(); |
|
|
|
|
|
articleOperateRecord.setCustomerId(customerId); |
|
|
|
|
|
articleOperateRecord.setArticleId(article.getId()); |
|
|
|
|
|
articleOperateRecord.setGridIds(formDTO.getGridIdList().stream().collect(Collectors.joining(":"))); |
|
|
|
|
|
articleOperateRecord.setOpUser(staffInfo.getAgencyName().concat("-").concat(staffInfo.getRealName())); |
|
|
|
|
|
articleOperateRecord.setContent(formDTO.getContent()); |
|
|
|
|
|
articleOperateRecord.setOpType(ArticleConstant.PUBLISH); |
|
|
|
|
|
articleOperateRecord.setOpTime(new Date()); |
|
|
|
|
|
articleOperateRecordService.insert(articleOperateRecord); |
|
|
|
|
|
// 4.发布范围
|
|
|
|
|
|
List<ArticlePublishRangeEntity> rangeList = new ArrayList<>(); |
|
|
|
|
|
formDTO.getGridIdList().forEach(g -> { |
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(g); |
|
|
|
|
|
if (null == gridInfo){ |
|
|
|
|
|
throw new EpmetException("未查询到网格信息:"+g); |
|
|
|
|
|
} |
|
|
|
|
|
ArticlePublishRangeEntity articlePublishRange = ConvertUtils.sourceToTarget(gridInfo,ArticlePublishRangeEntity.class); |
|
|
|
|
|
articlePublishRange.setCustomerId(customerId); |
|
|
|
|
|
articlePublishRange.setArticleId(article.getId()); |
|
|
|
|
|
articlePublishRange.setGridId(g); |
|
|
|
|
|
articlePublishRange.setAgencyGridName(gridInfo.getGridNamePath()); |
|
|
|
|
|
articlePublishRange.setAgencyId(gridInfo.getPid()); |
|
|
|
|
|
articlePublishRange.setPublishStatus(ArticleConstant.PUBLISHED); |
|
|
|
|
|
articlePublishRange.setId(null); |
|
|
|
|
|
rangeList.add(articlePublishRange); |
|
|
|
|
|
}); |
|
|
|
|
|
articlePublishRangeService.insertBatch(rangeList); |
|
|
|
|
|
// 5.文章标签
|
|
|
|
|
|
UpdateCustomerTagCacheDTO updateCustomerTagCacheDTO = updateCustomerTagV2(formDTO.getUserId(), formDTO.getCustomerId(), article.getTags()); |
|
|
|
|
|
addArticleTagsV2(updateCustomerTagCacheDTO,customerId,article.getId()); |
|
|
|
|
|
// 6.更新网格tag
|
|
|
|
|
|
List<UpdateGridTagCacheDTO> updateGridTagCacheDTOS = updateGridTagV2(updateCustomerTagCacheDTO, customerId, formDTO.getGridIdList(), formDTO.getUserId()); |
|
|
|
|
|
// 7.更新redis
|
|
|
|
|
|
try { |
|
|
|
|
|
this.updateCacheCustomerTag(updateCustomerTagCacheDTO); |
|
|
|
|
|
this.updateCacheGridTag(updateGridTagCacheDTOS); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("scanAllPassPublishArticle update redis exception", e); |
|
|
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
|
|
} |
|
|
|
|
|
}else {// 存草稿
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<PublishedListResultDTO> articleListV2(ArticleListFormDTO formDTO) { |
|
|
public PageData<PublishedListResultDTO> articleListV2(ArticleListFormDTO formDTO) { |
|
|
//1.获取工作人员缓存信息
|
|
|
//1.获取工作人员缓存信息
|
|
|