|
|
@ -45,8 +45,7 @@ import com.epmet.dto.feign.GovOrgSelfFeignClient; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.feign.EpmetUserClientFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserSelfFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.redis.ArticleRedis; |
|
|
|
import com.epmet.service.ArticleOperateRecordService; |
|
|
|
import com.epmet.service.ArticlePublishRangeService; |
|
|
@ -57,6 +56,7 @@ import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.jsoup.helper.StringUtil; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -88,7 +88,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Autowired |
|
|
|
private ArticlePublishRangeDao articlePublishRangeDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserSelfFeignClient epmetUserSelfFeignClient; |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private ArticleOperateRecordService articleOperateRecordService; |
|
|
|
@Autowired |
|
|
@ -96,8 +96,6 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
@Autowired |
|
|
|
private DraftPublishRangeDao draftPublishRangeDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserClientFeignClient epmetUserClientFeignClient; |
|
|
|
@Autowired |
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
private static final String AGENCY = "agency"; |
|
|
@ -206,7 +204,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
detailsFormDTO.setUserId(loginUserUtil.getLoginUserId()); |
|
|
|
detailsFormDTO.setApp(loginUserUtil.getLoginUserApp()); |
|
|
|
detailsFormDTO.setClient(loginUserUtil.getLoginUserClient()); |
|
|
|
Result<LoginUserDetailsResultDTO> loginUserDetails = epmetUserClientFeignClient.getLoginUserDetails(detailsFormDTO); |
|
|
|
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()); |
|
|
@ -536,7 +534,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
|
|
|
|
//4:文章操作记录表新增数据
|
|
|
|
//4.1:调用epmet-user服务,查询工作人员信息
|
|
|
|
Result<CustomerStaffDTO> resultStaff = epmetUserSelfFeignClient.getCustomerStaff(formDTO.getStaffId()); |
|
|
|
Result<CustomerStaffDTO> resultStaff = epmetUserOpenFeignClient.getCustomerStaff(formDTO.getStaffId()); |
|
|
|
if (null == resultStaff.getData()) { |
|
|
|
throw new RenException(ArticleConstant.SELECT_STAFF_EXCEPTION); |
|
|
|
} |
|
|
@ -558,12 +556,12 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
public PageData publishedArticleList(TokenDto tokenDto, PublishedListFormDTO formDTO) { |
|
|
|
PageHelper.startPage(formDTO.getPageNo(),formDTO.getPageSize()); |
|
|
|
List<PublishedListResultDTO> resultList; |
|
|
|
List<CustomerStaffRoleResultDTO> roles = epmetUserSelfFeignClient.getStaffRoles(tokenDto.getUserId()).getData(); |
|
|
|
List<CustomerStaffRoleResultDTO> roles = epmetUserOpenFeignClient.getStaffRoles(tokenDto.getUserId()).getData(); |
|
|
|
LoginUserDetailsFormDTO loginUserDetailsFormDTO = new LoginUserDetailsFormDTO(); |
|
|
|
loginUserDetailsFormDTO.setApp(tokenDto.getApp()); |
|
|
|
loginUserDetailsFormDTO.setClient(tokenDto.getClient()); |
|
|
|
loginUserDetailsFormDTO.setUserId(tokenDto.getUserId()); |
|
|
|
LoginUserDetailsResultDTO userInfo = epmetUserSelfFeignClient.getLoginUserDetails(loginUserDetailsFormDTO).getData(); |
|
|
|
LoginUserDetailsResultDTO userInfo = epmetUserOpenFeignClient.getLoginUserDetails(loginUserDetailsFormDTO).getData(); |
|
|
|
String staffLevel = ""; |
|
|
|
for (CustomerStaffRoleResultDTO role : roles) { |
|
|
|
//党建负责人
|
|
|
@ -595,7 +593,7 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
loginUserDetailsFormDTO.setApp(tokenDto.getApp()); |
|
|
|
loginUserDetailsFormDTO.setClient(tokenDto.getClient()); |
|
|
|
loginUserDetailsFormDTO.setUserId(tokenDto.getUserId()); |
|
|
|
LoginUserDetailsResultDTO userInfo = epmetUserSelfFeignClient.getLoginUserDetails(loginUserDetailsFormDTO).getData(); |
|
|
|
LoginUserDetailsResultDTO userInfo = epmetUserOpenFeignClient.getLoginUserDetails(loginUserDetailsFormDTO).getData(); |
|
|
|
List<OfflineListResultDTO> resultList = baseDao.selectOfflineList(userInfo.getGridIdList()); |
|
|
|
PageInfo<OfflineListResultDTO> pageInfo = new PageInfo<>(resultList); |
|
|
|
return new PageData<>(resultList, pageInfo.getTotal()); |
|
|
@ -650,19 +648,137 @@ public class ArticleServiceImpl extends BaseServiceImpl<ArticleDao, ArticleEntit |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public ArticleGridResultDTO publishGridList(PublishGridListFormDTO formDTO) { |
|
|
|
/*//1:查询当前文章发布范围内还未下线网格列表
|
|
|
|
//1:查询当前文章发布范围内还未下线网格列表
|
|
|
|
ArticlePublishRangeEntity rangeEntity = new ArticlePublishRangeEntity(); |
|
|
|
rangeEntity.setArticleId(formDTO.getArticleId()); |
|
|
|
rangeEntity.setPublishStatus(ArticleConstant.PUBLISHED); |
|
|
|
List<ArticlePublishRangeEntity> rangeEntityList = articlePublishRangeDao.selectByArticleId(rangeEntity); |
|
|
|
if(null==rangeEntityList||rangeEntityList.size()<NumConstant.ONE){ |
|
|
|
if (null == rangeEntityList || rangeEntityList.size() < NumConstant.ONE) { |
|
|
|
return new ArticleGridResultDTO(); |
|
|
|
} |
|
|
|
List<String> gridIdList = rangeEntityList.stream().map(ArticlePublishRangeEntity::getGridId).collect(Collectors.toList()); |
|
|
|
formDTO.setGridIdList(gridIdList);*/ |
|
|
|
|
|
|
|
return null; |
|
|
|
//2:查询当前工作人员的所属组织,以此作为根节点的起始位置
|
|
|
|
LoginUserDetailsFormDTO loginUserDetailsFormDTO = new LoginUserDetailsFormDTO(); |
|
|
|
loginUserDetailsFormDTO.setApp("gov"); |
|
|
|
loginUserDetailsFormDTO.setClient("wxmp"); |
|
|
|
loginUserDetailsFormDTO.setUserId(formDTO.getStaffId()); |
|
|
|
Result<LoginUserDetailsResultDTO> resultDTOResult = epmetUserOpenFeignClient.getLoginUserDetails(loginUserDetailsFormDTO); |
|
|
|
String agencyId = resultDTOResult.getData().getOrgIdPath(); |
|
|
|
//存放树的每一个节点对象,用于将同一节点下的网格列表合并(主键:agencyId 值:节点对象)
|
|
|
|
Map<String, ArticleGridResultDTO> map = new HashMap<>(); |
|
|
|
//3:循环可下线网格列表,根据pids组织每一个树节点对象信息
|
|
|
|
for (ArticlePublishRangeEntity range : rangeEntityList) { |
|
|
|
//当前网格的所有机关id
|
|
|
|
String gridPids = range.getPids() + ":" + range.getAgencyId(); |
|
|
|
//当前网格的所有机关名称
|
|
|
|
String gridAgencyNames = range.getAllParentName() + "-" + range.getAgencyGridName().substring(NumConstant.ZERO, range.getAgencyGridName().lastIndexOf("-")); |
|
|
|
String[] pids = gridPids.split(":"); |
|
|
|
String[] names = gridAgencyNames.split("-"); |
|
|
|
//倒序遍历
|
|
|
|
for (int i = (pids.length - NumConstant.ONE); i >= NumConstant.ZERO; i--) { |
|
|
|
//遍历到当前人员所属组织的上一级组织时停止遍历
|
|
|
|
if (i + NumConstant.ONE < pids.length && agencyId.equals(pids[i + NumConstant.ONE])) { |
|
|
|
break; |
|
|
|
} |
|
|
|
if (null == map.get(pids[i])) { |
|
|
|
ArticleGridResultDTO dto = new ArticleGridResultDTO(); |
|
|
|
dto.setAgencyId(pids[i]); |
|
|
|
dto.setAgencyName(names[i]); |
|
|
|
//根节点没有上级id的值
|
|
|
|
if (i > NumConstant.ZERO) { |
|
|
|
dto.setPid(pids[i - NumConstant.ONE]); |
|
|
|
} |
|
|
|
if (pids.length - NumConstant.ONE == i) { |
|
|
|
List<AgencyGridListResultDTO> gridList = new ArrayList<>(); |
|
|
|
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO(); |
|
|
|
gridDto.setGridId(range.getGridId()); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE)); |
|
|
|
gridList.add(gridDto); |
|
|
|
dto.setGridList(gridList); |
|
|
|
} |
|
|
|
map.put(pids[i], dto); |
|
|
|
} else { |
|
|
|
if (pids.length - NumConstant.ONE == i) { |
|
|
|
ArticleGridResultDTO dto1 = map.get(pids[i]); |
|
|
|
List<AgencyGridListResultDTO> gridList = dto1.getGridList(); |
|
|
|
AgencyGridListResultDTO gridDto = new AgencyGridListResultDTO(); |
|
|
|
gridDto.setGridId(range.getGridId()); |
|
|
|
gridDto.setGridName(range.getAgencyGridName().substring(range.getAgencyGridName().lastIndexOf("-") + NumConstant.ONE)); |
|
|
|
gridList.add(gridDto); |
|
|
|
dto1.setGridList(gridList); |
|
|
|
map.put(pids[i], dto1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//去除map中所有的节点对象,将list转成tree结构
|
|
|
|
List<ArticleGridResultDTO> resultDTOList = map.values().stream().collect(Collectors.toList()); |
|
|
|
List<ArticleGridResultDTO> list = agencyGridListToTree(resultDTOList); |
|
|
|
return list.get(NumConstant.ZERO); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 可下线网格列表-将list转为Tree结构 |
|
|
|
*/ |
|
|
|
private List<ArticleGridResultDTO> agencyGridListToTree(List<ArticleGridResultDTO> resultDTOList) { |
|
|
|
//根节点集合(pid为空)
|
|
|
|
List<ArticleGridResultDTO> listParentRecord = new ArrayList<>(); |
|
|
|
//非根节点集合(pid不为空)
|
|
|
|
List<ArticleGridResultDTO> listNotParentRecord = new ArrayList<>(); |
|
|
|
//1:遍历resultDTOList 保存所有数据的agencyId 用于判断是不是根节点
|
|
|
|
//agencyId
|
|
|
|
Map<String, String> agencyIdMap = new HashMap<>(); |
|
|
|
//每一个agencyId对应的节点对象信息
|
|
|
|
Map<String, ArticleGridResultDTO> allRecordMap = new HashMap<String, ArticleGridResultDTO>(); |
|
|
|
for (ArticleGridResultDTO dto : resultDTOList) { |
|
|
|
agencyIdMap.put(dto.getAgencyId(), dto.getAgencyId()); |
|
|
|
allRecordMap.put(dto.getAgencyId(), dto); |
|
|
|
} |
|
|
|
//2:遍历resultDTOList 找出所有的根节点和非根节点(pid是否为空)
|
|
|
|
if (resultDTOList != null && resultDTOList.size() > NumConstant.ZERO) { |
|
|
|
for (ArticleGridResultDTO record : resultDTOList) { |
|
|
|
//为空且存在
|
|
|
|
if (StringUtil.isBlank(record.getPid()) || !agencyIdMap.containsKey(record.getPid())) { |
|
|
|
listParentRecord.add(record); |
|
|
|
} else { |
|
|
|
listNotParentRecord.add(record); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//3:遍历根节点,递归获取所有子节点并添加到对应下级
|
|
|
|
for (ArticleGridResultDTO dto : listParentRecord) { |
|
|
|
//添加所有子级
|
|
|
|
List<ArticleGridResultDTO> subList = getSubTreeNodeList(listNotParentRecord, dto.getAgencyId()); |
|
|
|
dto.setSubAgencyGridList(subList); |
|
|
|
} |
|
|
|
return listParentRecord; |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 可下线网格列表-将list转为Tree结构-递归查询每一个根节点的下级节点集合 |
|
|
|
*/ |
|
|
|
private List<ArticleGridResultDTO> getSubTreeNodeList(List<ArticleGridResultDTO> listNotParentRecord, String agencyId) { |
|
|
|
List<ArticleGridResultDTO> subParentRecordList = new ArrayList<>(); |
|
|
|
List<ArticleGridResultDTO> subNotParentRecordList = new ArrayList<>(); |
|
|
|
//1:遍历tmpList,找出所有的根节点和非根节点
|
|
|
|
if (listNotParentRecord != null && listNotParentRecord.size() > NumConstant.ZERO) { |
|
|
|
for (ArticleGridResultDTO record : listNotParentRecord) { |
|
|
|
// 对比找出父节点
|
|
|
|
if (record.getPid().equals(agencyId)) { |
|
|
|
subParentRecordList.add(record); |
|
|
|
} else { |
|
|
|
subNotParentRecordList.add(record); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//2:层层递归添加下级查询子节点
|
|
|
|
for (ArticleGridResultDTO record : subParentRecordList) { |
|
|
|
//添加子节点
|
|
|
|
List<ArticleGridResultDTO> subList = getSubTreeNodeList(subNotParentRecordList, record.getAgencyId()); |
|
|
|
record.setSubAgencyGridList(subList); |
|
|
|
} |
|
|
|
return subParentRecordList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根绝文章Id查询出文章的内容、封面等相关信息,如果居民端传入的网格Id不在该文章的发布范围内,则返回NULL |
|
|
|
* @param articleDetailFormDTO |
|
|
|