|
|
@ -31,20 +31,26 @@ import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.constant.ArticleConstant; |
|
|
|
import com.epmet.dao.ArticleDao; |
|
|
|
import com.epmet.dao.ArticlePublishRangeDao; |
|
|
|
import com.epmet.dao.DraftContentDao; |
|
|
|
import com.epmet.dao.DraftDao; |
|
|
|
import com.epmet.dto.ArticleDTO; |
|
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
|
import com.epmet.dto.CustomerStaffDTO; |
|
|
|
import com.epmet.dto.feign.GovOrgSelfFeignClient; |
|
|
|
import com.epmet.dto.form.DraftContentFromDTO; |
|
|
|
import com.epmet.dto.form.OffLineArticleFormDTO; |
|
|
|
import com.epmet.dto.result.ArticleGridResultDTO; |
|
|
|
import com.epmet.dto.result.GovArticleContentDTO; |
|
|
|
import com.epmet.dto.result.GovArticleDetailResultDTO; |
|
|
|
import com.epmet.dto.result.PublishAgencyListResultDTO; |
|
|
|
import com.epmet.entity.ArticleEntity; |
|
|
|
import com.epmet.entity.DraftContentEntity; |
|
|
|
import com.epmet.entity.DraftEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.feign.EpmetUserSelfFeignClient; |
|
|
|
import com.epmet.redis.ArticleRedis; |
|
|
|
import com.epmet.service.ArticleOperateRecordService; |
|
|
|
import com.epmet.service.ArticlePublishRangeService; |
|
|
|
import com.epmet.service.ArticleService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
@ -55,6 +61,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
|
|
|
|
/** |
|
|
|
* 文章表 |
|
|
@ -73,6 +80,14 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
private DraftDao draftDao; |
|
|
|
@Autowired |
|
|
|
private DraftContentDao draftContentDao; |
|
|
|
@Autowired |
|
|
|
private ArticlePublishRangeService articlePublishRangeService; |
|
|
|
@Autowired |
|
|
|
private ArticlePublishRangeDao articlePublishRangeDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserSelfFeignClient epmetUserSelfFeignClient; |
|
|
|
@Autowired |
|
|
|
private ArticleOperateRecordService articleOperateRecordService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ArticleDTO> page(Map<String, Object> params) { |
|
|
@ -137,17 +152,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
Result<ArticleGridResultDTO> result = govOrgSelfFeignClient.getAgencyGridList(tokenDTO.getUserId()); |
|
|
|
return result.getData(); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @param tokenDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 党建声音-政府端-可选发布范围 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public ArticleGridResultDTO agencyGridList(TokenDto tokenDTO) { |
|
|
|
Result<ArticleGridResultDTO> result = govOrgSelfFeignClient.getAgencyGridList(tokenDTO.getUserId()); |
|
|
|
return result.getData(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param tokenDTO |
|
|
@ -254,4 +258,91 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
return newContentList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
* @Author sun |
|
|
|
* @Description 党建声音-政府端-下线文章 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void offLineArticle(OffLineArticleFormDTO formDTO) { |
|
|
|
//1:根据文章Id查询全部(已发布、已下线)发布范围数据
|
|
|
|
ArticlePublishRangeEntity rangeEntity = new ArticlePublishRangeEntity(); |
|
|
|
rangeEntity.setArticleId(formDTO.getArticleId()); |
|
|
|
List<ArticlePublishRangeEntity> rangeEntityList = articlePublishRangeDao.selectByArticleId(rangeEntity); |
|
|
|
if (null == rangeEntityList || rangeEntityList.size() < NumConstant.ONE) { |
|
|
|
throw new RenException(ArticleConstant.RANGE_DATA_EXCEPTION); |
|
|
|
} |
|
|
|
|
|
|
|
//2:批量更新发布范围数据,将前台勾选的文章网格列表数据置为下线状态
|
|
|
|
Date date = new Date(); |
|
|
|
//还未下线的发布范围列表
|
|
|
|
List<ArticlePublishRangeEntity> publishedList = new ArrayList<>(); |
|
|
|
//将要下线的发布范围列表
|
|
|
|
List<ArticlePublishRangeEntity> offLineList = new ArrayList<>(); |
|
|
|
rangeEntityList.forEach(entity -> { |
|
|
|
if (entity.getPublishStatus().equals(ArticleConstant.PUBLISHED)) { |
|
|
|
//是否下线(true:是)
|
|
|
|
AtomicBoolean isOffLine = new AtomicBoolean(false); |
|
|
|
formDTO.getGridIdList().forEach(gridId -> { |
|
|
|
if (entity.getGridId().equals(gridId)) { |
|
|
|
isOffLine.set(true); |
|
|
|
entity.setOffLineTime(date); |
|
|
|
entity.setPublishStatus(ArticleConstant.OFFLINE); |
|
|
|
offLineList.add(entity); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (!isOffLine.get()) { |
|
|
|
publishedList.add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
//2.1:批量更新发布范围表数据
|
|
|
|
articlePublishRangeService.updateBatchById(offLineList); |
|
|
|
|
|
|
|
//3:根据是否全部下线更新文章主表数据
|
|
|
|
ArticleEntity entity = new ArticleEntity(); |
|
|
|
entity.setId(formDTO.getArticleId()); |
|
|
|
StringBuffer publishRangeDesc = new StringBuffer(); |
|
|
|
if (null == publishedList || publishedList.size() < NumConstant.ONE) { |
|
|
|
entity.setStatusFlag(ArticleConstant.OFFLINE); |
|
|
|
entity.setOffLineTime(date); |
|
|
|
rangeEntityList.forEach(range -> { |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : ""); |
|
|
|
publishRangeDesc.append(range.getAgencyGridName()); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
publishedList.forEach(pub -> { |
|
|
|
publishRangeDesc.append(publishRangeDesc.length() > NumConstant.ZERO ? "、" : ""); |
|
|
|
publishRangeDesc.append(pub.getAgencyGridName()); |
|
|
|
}); |
|
|
|
} |
|
|
|
entity.setPublishRangeDesc(publishRangeDesc.toString()); |
|
|
|
baseDao.updateById(entity); |
|
|
|
|
|
|
|
//4:文章操作记录表新增数据
|
|
|
|
//4.1:调用epmet-user服务,查询工作人员信息
|
|
|
|
Result<CustomerStaffDTO> resultStaff = epmetUserSelfFeignClient.getCustomerStaff(formDTO.getStaffId()); |
|
|
|
if (null == resultStaff.getData()) { |
|
|
|
throw new RenException(ArticleConstant.SELECT_STAFF_EXCEPTION); |
|
|
|
} |
|
|
|
CustomerStaffDTO staffDTO = resultStaff.getData(); |
|
|
|
//4.2:调用gov-org服务,查询当前人员所属组织机构信息
|
|
|
|
Result<CustomerAgencyDTO> resultAgency = govOrgSelfFeignClient.getAgencyByStaffId(formDTO.getStaffId()); |
|
|
|
if (null == resultAgency.getData()) { |
|
|
|
throw new RenException(ArticleConstant.SELECT_AGRNCY_EXCEPTION); |
|
|
|
} |
|
|
|
CustomerAgencyDTO agencyDTO = resultAgency.getData(); |
|
|
|
//4.3:新增操作表数据
|
|
|
|
ArticleOperateRecordEntity recordEntity = new ArticleOperateRecordEntity(); |
|
|
|
recordEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
recordEntity.setArticleId(formDTO.getArticleId()); |
|
|
|
recordEntity.setOpUser(agencyDTO.getOrganizationName() + "-" + staffDTO.getRealName()); |
|
|
|
recordEntity.setContent(recordEntity.getOpUser() + ArticleConstant.OFF_LINE_ARTICLE); |
|
|
|
recordEntity.setOpType(ArticleConstant.OFFLINE); |
|
|
|
recordEntity.setOpTime(date); |
|
|
|
articleOperateRecordService.insert(recordEntity); |
|
|
|
} |
|
|
|
|
|
|
|
} |