|  |  | @ -17,24 +17,30 @@ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.service.impl; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.FieldConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.exception.EpmetException; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.redis.common.CustomerStaffRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.user.LoginUserUtil; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.DraftConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.DraftContentDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.DraftCoverDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.DraftDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dao.DraftPublishRangeDao; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.DraftDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.DeleteDraftFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.DraftDetailFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.DraftListFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.result.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.DraftCoverEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.DraftEntity; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.entity.*; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.DraftService; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageHelper; | 
			
		
	
		
			
				
					|  |  |  | import com.github.pagehelper.PageInfo; | 
			
		
	
	
		
			
				
					|  |  | @ -44,11 +50,10 @@ import org.slf4j.LoggerFactory; | 
			
		
	
		
			
				
					|  |  |  | 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.ArrayList; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Arrays; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Map; | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | /** | 
			
		
	
		
			
				
					|  |  |  |  * 草稿表 | 
			
		
	
	
		
			
				
					|  |  | @ -62,6 +67,13 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DraftCoverDao draftCoverDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private LoginUserUtil loginUserUtil; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DraftPublishRangeDao draftPublishRangeDao; | 
			
		
	
		
			
				
					|  |  |  |     @Autowired | 
			
		
	
		
			
				
					|  |  |  |     private DraftContentDao draftContentDao; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<DraftDTO> page(Map<String, Object> params) { | 
			
		
	
		
			
				
					|  |  |  |         IPage<DraftEntity> page = baseDao.selectPage( | 
			
		
	
	
		
			
				
					|  |  | @ -203,12 +215,66 @@ public class DraftServiceImpl extends BaseServiceImpl<DraftDao, DraftEntity> imp | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public PageData<DraftPcListResultDTO> draftListV2(DraftListFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |         //1.获取工作人员缓存信息
 | 
			
		
	
		
			
				
					|  |  |  |         CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getStaffId()); | 
			
		
	
		
			
				
					|  |  |  |         if (null == staffInfo) { | 
			
		
	
		
			
				
					|  |  |  |             throw new EpmetException("获取工作人员信息失败"); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         //查询当前组织及下级数据
 | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setAgencyId(staffInfo.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  |         //列表查询
 | 
			
		
	
		
			
				
					|  |  |  |         PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); | 
			
		
	
		
			
				
					|  |  |  |         List<DraftPcListResultDTO> list = baseDao.selectAllDraft(formDTO); | 
			
		
	
		
			
				
					|  |  |  |         PageInfo<DraftPcListResultDTO> pageInfo = new PageInfo<>(list); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //封装数据
 | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |             list.forEach(l->{ | 
			
		
	
		
			
				
					|  |  |  |                 l.setTagNameList(StringUtils.isNotBlank(l.getTags())?Arrays.asList(l.getTags().split("[|]")):new ArrayList<>()); | 
			
		
	
		
			
				
					|  |  |  |                 l.setIsMePublished(l.getCreatedBy().equals(loginUserUtil.getLoginUserId())?true:false); | 
			
		
	
		
			
				
					|  |  |  |             }); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return new PageData<>(list, pageInfo.getTotal()); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @Override | 
			
		
	
		
			
				
					|  |  |  |     public DraftPcListResultDTO detailV2(DraftListFormDTO formDTO) { | 
			
		
	
		
			
				
					|  |  |  |         return null; | 
			
		
	
		
			
				
					|  |  |  |         DraftPcListResultDTO resultDTO = new DraftPcListResultDTO(); | 
			
		
	
		
			
				
					|  |  |  |         //1.查询文章主表信息
 | 
			
		
	
		
			
				
					|  |  |  |         List<DraftPcListResultDTO> list = baseDao.selectAllDraft(formDTO); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         if (!CollectionUtils.isEmpty(list)) { | 
			
		
	
		
			
				
					|  |  |  |             resultDTO = list.get(NumConstant.ZERO); | 
			
		
	
		
			
				
					|  |  |  |             //查询文章涉及的发布范围网络Id列表
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaQueryWrapper<DraftPublishRangeEntity> tWrapper = new LambdaQueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             tWrapper.eq(DraftPublishRangeEntity::getDraftId, formDTO.getDraftId()); | 
			
		
	
		
			
				
					|  |  |  |             tWrapper.eq(DraftPublishRangeEntity::getDelFlag, NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             //【文章下线的查所有发布范围,文章没下线的只查还没下线的发布范围】
 | 
			
		
	
		
			
				
					|  |  |  |             if("unpublish".equals(resultDTO.getStatusFlag())){ | 
			
		
	
		
			
				
					|  |  |  |                 tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "unpublish"); | 
			
		
	
		
			
				
					|  |  |  |             }else { | 
			
		
	
		
			
				
					|  |  |  |                 tWrapper.eq(DraftPublishRangeEntity::getPublishStatus, "published"); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             List<DraftPublishRangeEntity> entityList = draftPublishRangeDao.selectList(tWrapper); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(entityList)) { | 
			
		
	
		
			
				
					|  |  |  |                 List<String> contentList = entityList.stream().map(DraftPublishRangeEntity::getGridId).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |                 resultDTO.setGridIdList(contentList); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             //查询文章内容
 | 
			
		
	
		
			
				
					|  |  |  |             LambdaQueryWrapper<DraftContentEntity> tWrapper1 = new LambdaQueryWrapper<>(); | 
			
		
	
		
			
				
					|  |  |  |             tWrapper1.eq(DraftContentEntity::getDraftId, formDTO.getDraftId()); | 
			
		
	
		
			
				
					|  |  |  |             tWrapper1.eq(DraftContentEntity::getDelFlag, NumConstant.ZERO_STR); | 
			
		
	
		
			
				
					|  |  |  |             tWrapper1.orderByDesc(DraftContentEntity::getOrderNum); | 
			
		
	
		
			
				
					|  |  |  |             List<DraftContentEntity> contentEntityList = draftContentDao.selectList(tWrapper1); | 
			
		
	
		
			
				
					|  |  |  |             if (!CollectionUtils.isEmpty(entityList)) { | 
			
		
	
		
			
				
					|  |  |  |                 LinkedList<String> contentList = (LinkedList)contentEntityList.stream().map(DraftContentEntity::getContent).collect(Collectors.toList()); | 
			
		
	
		
			
				
					|  |  |  |                 resultDTO.setContentList(contentList); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return resultDTO; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | } |