|
|
@ -56,6 +56,7 @@ 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; |
|
|
@ -67,6 +68,7 @@ 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; |
|
|
@ -173,12 +175,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
log.debug("saveOrUpdateContent param:{}", JSON.toJSONString(fromDTO)); |
|
|
|
if (required) { |
|
|
|
ValidatorUtils.validateEntity(fromDTO); |
|
|
|
if (StringUtils.isBlank(fromDTO.getTitle())){ |
|
|
|
throw new RenException(ModuleConstant.ARTICLE_TITLE_IS_NULL); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(fromDTO.getContentList())){ |
|
|
|
throw new RenException(ModuleConstant.ARTICLE_CONTENT_IS_NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DraftEntity draftEntity = null; |
|
|
@ -196,7 +192,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
Result<LoginUserDetailsResultDTO> loginUserDetails = epmetUserOpenFeignClient.getLoginUserDetails(detailsFormDTO); |
|
|
|
if (loginUserDetails == null || loginUserDetails.getData() == null) { |
|
|
|
log.warn("saveOrUpdateContent getloginUserDetails return null"); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), EpmetErrorCode.SERVER_ERROR.getMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), ModuleConstant.GET_USER_DETAIL_ERROR); |
|
|
|
} |
|
|
|
draftEntity = new DraftEntity(); |
|
|
|
draftEntity.setTitle(fromDTO.getTitle()); |
|
|
@ -287,23 +283,18 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
draftEntity.setIsTop(fromDTO.getIsTop()); |
|
|
|
|
|
|
|
//发布单位
|
|
|
|
if (StringUtils.isNotBlank(fromDTO.getPublisher())){ |
|
|
|
String publisherType = fromDTO.getPublisherType(); |
|
|
|
String publisherName = fromDTO.getPublisherName(); |
|
|
|
if (StringUtils.isBlank(publisherType) || StringUtils.isBlank(publisherName)) { |
|
|
|
log.warn("saveDraftAttr publisher info is illegal,publisher:{},publisherType:{},publisherName:{}",fromDTO.getPublisher(),publisherType,publisherName); |
|
|
|
throw new RenException("发布单位不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
draftEntity.setPublisherName(fromDTO.getPublisherName()); |
|
|
|
draftEntity.setPublisherId(fromDTO.getPublisher()); |
|
|
|
draftEntity.setPublisherType(fromDTO.getPublisherType()); |
|
|
|
|
|
|
|
//TODO ? 如果为机关 不设置?
|
|
|
|
if(DraftConstant.GRID.equals(fromDTO.getPublisherType())) { |
|
|
|
draftEntity.setGridId(fromDTO.getPublisher()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(fromDTO.getPublishDate())){ |
|
|
|
draftEntity.setPublishDate(DateUtils.stringToDate(fromDTO.getPublishDate(),DateUtils.DATE_PATTERN)); |
|
|
|
} |
|
|
|
|
|
|
|
//封面
|
|
|
|
DraftCoverEntity coverEntity = buildCoverEntity(tokenDto, fromDTO); |
|
|
@ -319,16 +310,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
DraftEntity draftEntity = draftDao.selectById(draftId); |
|
|
|
if (draftEntity == null) { |
|
|
|
log.warn("saveDraftAttr draftId:{} is not exist in db",draftId); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
throw new RenException(ModuleConstant.DRAFT_ID_IS_NOT_EXIST); |
|
|
|
} |
|
|
|
if (NumConstant.ONE_STR.equals(draftEntity.getDelFlag())) { |
|
|
|
log.warn("saveDraftAttr draftId:{} have deleted",draftId); |
|
|
|
throw new RenException("草稿已删除"); |
|
|
|
throw new RenException(ModuleConstant.DRAFT_STATUS_IS_DEL); |
|
|
|
} |
|
|
|
//只有为发布的才能保存修改
|
|
|
|
//只有未发布的和审核失败的才能修改
|
|
|
|
if (DraftConstant.AUDITING.equals(draftEntity.getStatusFlag()) || DraftConstant.PUBLISHED.equals(draftEntity.getStatusFlag())) { |
|
|
|
log.warn("saveDraftAttr draftId:{} publishStatus have published",draftId); |
|
|
|
throw new RenException("草稿发布状态错误"); |
|
|
|
throw new RenException(ModuleConstant.DRAFT_STATUS_IS_NOT_ALLOW_MODIFY); |
|
|
|
} |
|
|
|
return draftEntity; |
|
|
|
} |
|
|
@ -336,23 +327,21 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Override |
|
|
|
public Boolean previewSaveDraftAttr(TokenDto tokenDto, DraftAttrFromDTO fromDTO) { |
|
|
|
//校验参数
|
|
|
|
ValidatorUtils.validateEntity(fromDTO); |
|
|
|
if (DraftConstant.TOP.equals(fromDTO.getIsTop()) && StringUtils.isBlank(fromDTO.getCoverImg())) { |
|
|
|
log.warn("saveOrUpdateAttr isTop=1 but coverImg is blank"); |
|
|
|
throw new RenException("文章封面不能为空"); |
|
|
|
throw new RenException(ModuleConstant.DRAFT_CONTENT_IS_NULL); |
|
|
|
} |
|
|
|
if (CollectionUtils.isEmpty(fromDTO.getGridIdList())) { |
|
|
|
log.warn("saveOrUpdateAttr gridIdList is empty"); |
|
|
|
throw new RenException("发布范围不能为空"); |
|
|
|
if (StringUtils.isBlank(fromDTO.getPublisherName()) || StringUtils.isBlank(fromDTO.getPublisherType())) { |
|
|
|
throw new RenException(ModuleConstant.DRAFT_PUBLISHER_IS_NULL); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(fromDTO.getPublisher())) { |
|
|
|
log.warn("saveOrUpdateAttr publisher is blank"); |
|
|
|
throw new RenException("发布单位不能为空"); |
|
|
|
if (fromDTO.getIsTop() == null || fromDTO.getIsTop() > 1 || fromDTO.getIsTop() < 0) { |
|
|
|
throw new RenException(ModuleConstant.DRAFT_IS_TOP_ERROR); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isBlank(fromDTO.getPublishDate())) { |
|
|
|
log.warn("saveOrUpdateAttr publishDate is blank"); |
|
|
|
throw new RenException("发布时间不能为空"); |
|
|
|
if ( fromDTO.getPublisherType() != DraftConstant.AGENCY && fromDTO.getPublisherType() != DraftConstant.DEPARTMENT |
|
|
|
&&fromDTO.getPublisherType() != DraftConstant.GRID) { |
|
|
|
throw new RenException(ModuleConstant.DRAFT_PUBLISHER_TYPE_ERROR); |
|
|
|
} |
|
|
|
return saveDraftAttr(tokenDto, fromDTO); |
|
|
|
} |
|
|
@ -361,7 +350,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
public Boolean publish(TokenDto tokenDto, String draftId) { |
|
|
|
if (StringUtils.isBlank(draftId)){ |
|
|
|
log.warn("publish param error draftId is blank"); |
|
|
|
throw new RenException("草稿Id不能为空"); |
|
|
|
throw new RenException(ModuleConstant.DRAFT_ID_IS_NULL); |
|
|
|
} |
|
|
|
DraftEntity draftEntity = checkDraftStatus(draftId); |
|
|
|
draftEntity.setStatusFlag(DraftConstant.AUDITING); |
|
|
@ -395,11 +384,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
ArticleGridResultDTO articleGridResultDTO = this.agencyGridList(tokenDto); |
|
|
|
if (articleGridResultDTO == null) { |
|
|
|
log.warn("saveDraftAttr userId:{} have not right access publishRange", tokenDto.getUserId()); |
|
|
|
throw new RenException("参数错误"); |
|
|
|
throw new RenException(ModuleConstant.GET_USER_CAN_SELECT_GRID_ERROR); |
|
|
|
} |
|
|
|
buildName(tokenDto,agencyGridNameList,publishRangeEntityList, fromDTO, articleGridResultDTO); |
|
|
|
buildAgencyGridNames(tokenDto,agencyGridNameList,publishRangeEntityList, fromDTO, articleGridResultDTO); |
|
|
|
draftEntity.setPublishRangeDesc(StringUtils.join(agencyGridNameList,"、")); |
|
|
|
draftEntity.setPublishRangeDesc(StringUtils.join(agencyGridNameList, StrConstant.COMMA_ZH)); |
|
|
|
return publishRangeEntityList; |
|
|
|
} |
|
|
|
|
|
|
@ -436,7 +425,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
if (!CollectionUtils.isEmpty(gridList)&&!CollectionUtils.isEmpty(gridIdList)) { |
|
|
|
gridList.forEach(grid -> { |
|
|
|
if (gridIdList.contains(grid.getGridId())) { |
|
|
|
String agencyGridName = articleGridResultDTO.getAgencyName().concat("-").concat(grid.getGridName()); |
|
|
|
String agencyGridName = articleGridResultDTO.getAgencyName().concat(StrConstant.HYPHEN).concat(grid.getGridName()); |
|
|
|
agencyGridNameList.add(agencyGridName); |
|
|
|
DraftPublishRangeEntity draftPublishRangeEntity = new DraftPublishRangeEntity(); |
|
|
|
draftPublishRangeEntity.setCustomerId(tokenDto.getCustomerId()); |
|
|
@ -471,19 +460,17 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
List<DraftContentEntity> newContentList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < contentList.size(); i++) { |
|
|
|
for (int i = NumConstant.ZERO; i < contentList.size(); i++) { |
|
|
|
DraftContentFromDTO.DraftContentDTO content = contentList.get(i); |
|
|
|
DraftContentEntity entity = ConvertUtils.sourceToTarget(content, DraftContentEntity.class); |
|
|
|
entity.setId(content.getDraftContentId()); |
|
|
|
entity.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
entity.setDraftId(fromDTO.getDraftId()); |
|
|
|
entity.setOrderNum(i + 1); |
|
|
|
//默认通过
|
|
|
|
entity.setOrderNum(i + NumConstant.ONE); |
|
|
|
//默认为空
|
|
|
|
entity.setAuditStatus(""); |
|
|
|
newContentList.add(entity); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return newContentList; |
|
|
|
} |
|
|
|
|
|
|
@ -543,16 +530,16 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
ArticleEntity entity = new ArticleEntity(); |
|
|
|
entity.setId(formDTO.getArticleId()); |
|
|
|
StringBuffer publishRangeDesc = new StringBuffer(); |
|
|
|
if (null == publishedList || publishedList.size() < NumConstant.ONE) { |
|
|
|
if (CollectionUtils.isEmpty(publishedList)) { |
|
|
|
entity.setStatusFlag(ArticleConstant.OFFLINE); |
|
|
|
entity.setOffLineTime(date); |
|
|
|
rangeEntityList.forEach(range -> { |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : ""); |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : ""); |
|
|
|
publishRangeDesc.append(range.getAgencyGridName()); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
publishedList.forEach(pub -> { |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : ""); |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? StrConstant.COMMA_ZH : ""); |
|
|
|
publishRangeDesc.append(pub.getAgencyGridName()); |
|
|
|
}); |
|
|
|
} |
|
|
@ -566,7 +553,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
ArticleOperateRecordEntity recordEntity = new ArticleOperateRecordEntity(); |
|
|
|
recordEntity.setCustomerId(articleEntity.getCustomerId()); |
|
|
|
recordEntity.setArticleId(formDTO.getArticleId()); |
|
|
|
recordEntity.setOpUser(articleEntity.getPublisherName() + "-" + staffDTO.getRealName()); |
|
|
|
recordEntity.setOpUser(articleEntity.getPublisherName() + StrConstant.HYPHEN + staffDTO.getRealName()); |
|
|
|
//下线文案,分为全部下线和部分下线
|
|
|
|
String content = ""; |
|
|
|
if (null == publishedList || publishedList.size() < NumConstant.ONE) { |
|
|
@ -574,7 +561,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
} else { |
|
|
|
StringBuffer offLineRangeDesc = new StringBuffer(); |
|
|
|
offLineList.forEach(off -> { |
|
|
|
offLineRangeDesc.append(offLineRangeDesc.length() > NumConstant.ZERO ? "、" : ""); |
|
|
|
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); |
|
|
@ -721,9 +708,9 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
//当前网格的所有机关id
|
|
|
|
String gridPids = range.getPids() + ":" + range.getAgencyId(); |
|
|
|
//当前网格的所有机关名称
|
|
|
|
String gridAgencyNames = range.getAllParentName() + "-" + range.getAgencyGridName().substring(NumConstant.ZERO, range.getAgencyGridName().lastIndexOf("-")); |
|
|
|
String gridAgencyNames = range.getAllParentName() + StrConstant.HYPHEN + range.getAgencyGridName().substring(NumConstant.ZERO, range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN)); |
|
|
|
String[] pids = gridPids.split(":"); |
|
|
|
String[] names = gridAgencyNames.split("-"); |
|
|
|
String[] names = gridAgencyNames.split(StrConstant.HYPHEN); |
|
|
|
//倒序遍历
|
|
|
|
for (int i = (pids.length - NumConstant.ONE); i >= NumConstant.ZERO; i--) { |
|
|
|
//遍历到当前人员所属组织的上一级组织时停止遍历
|
|
|
@ -742,7 +729,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
List<AgencyGridListResultDTO> gridList = new ArrayList<>(); |
|
|
|
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO(); |
|
|
|
gridDto.setGridId(range.getGridId()); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE)); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN) + NumConstant.ONE)); |
|
|
|
gridList.add(gridDto); |
|
|
|
dto.setGridList(gridList); |
|
|
|
} |
|
|
@ -753,7 +740,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
List<AgencyGridListResultDTO> gridList = dto1.getGridList(); |
|
|
|
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO(); |
|
|
|
gridDto.setGridId(range.getGridId()); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE)); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf(StrConstant.HYPHEN) + NumConstant.ONE)); |
|
|
|
gridList.add(gridDto); |
|
|
|
dto1.setGridList(gridList); |
|
|
|
map.put(pids[i], dto1); |
|
|
@ -1099,11 +1086,11 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
if (coverFail || contentFail){ |
|
|
|
String auditMsg = ""; |
|
|
|
if (coverFail&&contentFail){ |
|
|
|
auditMsg = "内容和封面"; |
|
|
|
auditMsg = ModuleConstant.DRAFT_CONTENT_AND_COVER; |
|
|
|
}else if (contentFail){ |
|
|
|
auditMsg = "内容"; |
|
|
|
auditMsg = ModuleConstant.DRAFT_CONTENT; |
|
|
|
}else if (coverFail){ |
|
|
|
auditMsg = "封面"; |
|
|
|
auditMsg = ModuleConstant.DRAFT_COVER;; |
|
|
|
} |
|
|
|
this.sendMsg(draft.getCustomerId(), draft.getTitle(), String.format(ModuleConstant.MSG_AUDIT_CONTENT, draft.getTitle(),auditMsg)); |
|
|
|
} |
|
|
|