|
|
@ -18,31 +18,26 @@ |
|
|
|
package com.epmet.modules.notice.service.impl; |
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
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.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.dto.form.LoginUserDetailsFormDTO; |
|
|
|
import com.epmet.dto.form.UserMessageFormDTO; |
|
|
|
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|
|
|
import com.epmet.dto.result.GridInfoResultDTO; |
|
|
|
import com.epmet.dto.result.UserBaseInfoResultDTO; |
|
|
|
import com.epmet.feign.EpmetMessageOpenFeignClient; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.feign.GovOrgOpenFeignClient; |
|
|
|
import com.epmet.modules.constant.UserMessageConstant; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupDao; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupEntity; |
|
|
@ -63,10 +58,9 @@ import com.epmet.resi.group.dto.notice.NoticeDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.AddNoticeFormDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.EditNoticeFormDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.NoticeDetailFormDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.form.NoticeFileDTO; |
|
|
|
import com.epmet.resi.group.dto.notice.result.NoticeDetailResultDTO; |
|
|
|
import com.epmet.resi.group.dto.topic.form.FileDTO; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -74,7 +68,10 @@ import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.concurrent.atomic.AtomicReference; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -103,6 +100,8 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
@Autowired |
|
|
|
private NoticeAttachmentService noticeAttachmentService; |
|
|
@ -111,7 +110,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
@Autowired |
|
|
|
private NoticeReadRecordService noticeReafdRecordService; |
|
|
|
@Autowired |
|
|
|
private NoticeReadRecordDao noticeReafdRecordDao; |
|
|
|
private NoticeReadRecordDao noticeReadRecordDao; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@ -128,7 +127,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void add(TokenDto tokenDto, AddNoticeFormDTO formDTO) { |
|
|
|
public void add(AddNoticeFormDTO formDTO) { |
|
|
|
//1.查询组内成员数据
|
|
|
|
List<ResiGroupMemberDTO> memberList = resiGroupMemberDao.getMemberList(formDTO.getGroupId()); |
|
|
|
if (CollUtil.isEmpty(memberList)) { |
|
|
@ -138,7 +137,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
//2.校验当前操作人员是否为组长
|
|
|
|
AtomicReference<Boolean> bl = new AtomicReference<>(true); |
|
|
|
memberList.forEach(m -> { |
|
|
|
if (m.getCustomerUserId().equals(tokenDto.getUserId()) && "leader".equals(m.getGroupLeaderFlag())) { |
|
|
|
if (m.getCustomerUserId().equals(formDTO.getUserId()) && "leader".equals(m.getGroupLeaderFlag())) { |
|
|
|
bl.set(false); |
|
|
|
} |
|
|
|
}); |
|
|
@ -150,30 +149,27 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
List<String> wordList = new ArrayList<>(); |
|
|
|
wordList.add(formDTO.getTitle()); |
|
|
|
wordList.add(formDTO.getContent()); |
|
|
|
List<String> imageList = formDTO.getImageList().stream().map(FileDTO::getUrl).collect(Collectors.toList()); |
|
|
|
List<String> imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); |
|
|
|
safetyCheck(wordList, imageList); |
|
|
|
|
|
|
|
//4.保存小组通知基础数据
|
|
|
|
//4-1.获取小组信息
|
|
|
|
ResiGroupEntity groupEntity = resiGroupDao.selectById(formDTO.getGroupId()); |
|
|
|
if (null == groupEntity) { |
|
|
|
throw new RenException(String.format("保存小组通知,获取小组数据失败,小组Id->", tokenDto.getUserId())); |
|
|
|
throw new RenException(String.format("保存小组通知,获取小组数据失败,小组Id->", formDTO.getUserId())); |
|
|
|
} |
|
|
|
//4-2.获取token用户所属组织信息
|
|
|
|
LoginUserDetailsFormDTO dto = new LoginUserDetailsFormDTO(); |
|
|
|
dto.setApp(tokenDto.getApp()); |
|
|
|
dto.setClient(tokenDto.getClient()); |
|
|
|
dto.setUserId(tokenDto.getUserId()); |
|
|
|
Result<LoginUserDetailsResultDTO> result = epmetUserOpenFeignClient.getLoginUserDetails(dto); |
|
|
|
if (!result.success() || org.springframework.util.StringUtils.isEmpty(result.getData().getAgencyId())) { |
|
|
|
throw new RenException(String.format("调用user服务查询用户数据失败,userId->", tokenDto.getUserId())); |
|
|
|
Result<GridInfoResultDTO> result = govOrgOpenFeignClient.queryGridInfo(groupEntity.getGridId()); |
|
|
|
if (!result.success() || org.springframework.util.StringUtils.isEmpty(result.getData().getParentAgencyId())) { |
|
|
|
throw new RenException(String.format("调用user服务查询用户数据失败,userId->", formDTO.getUserId())); |
|
|
|
} |
|
|
|
LoginUserDetailsResultDTO resultDTO = result.getData(); |
|
|
|
GridInfoResultDTO resultDTO = result.getData(); |
|
|
|
|
|
|
|
|
|
|
|
//4-3.保存通知数据
|
|
|
|
NoticeEntity entity = new NoticeEntity(); |
|
|
|
entity.setCustomerId(resultDTO.getCustomerId()); |
|
|
|
entity.setAgencyId(resultDTO.getAgencyId()); |
|
|
|
entity.setAgencyId(resultDTO.getParentAgencyId()); |
|
|
|
entity.setGridId(groupEntity.getGridId()); |
|
|
|
entity.setGroupId(formDTO.getGroupId()); |
|
|
|
entity.setTitle(formDTO.getTitle()); |
|
|
@ -237,7 +233,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
if ("leader".equals(m.getGroupLeaderFlag())) { |
|
|
|
reafdRecord.setReadFlag(ReadFlagConstant.READ); |
|
|
|
}else { |
|
|
|
reafdRecord.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
reafdRecord.setReadFlag("un_read"); |
|
|
|
} |
|
|
|
reafdRecordList.add(reafdRecord); |
|
|
|
}); |
|
|
@ -274,7 +270,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
* @Description 小组通知变更 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public void edit(TokenDto tokenDto, EditNoticeFormDTO formDTO) { |
|
|
|
public void edit(EditNoticeFormDTO formDTO) { |
|
|
|
//1.查询通知是否存在
|
|
|
|
NoticeEntity entity = baseDao.selectById(formDTO.getNoticeId()); |
|
|
|
if (null == entity) { |
|
|
@ -284,7 +280,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
List<String> wordList = new ArrayList<>(); |
|
|
|
wordList.add(formDTO.getTitle()); |
|
|
|
wordList.add(formDTO.getContent()); |
|
|
|
List<String> imageList = formDTO.getImageList().stream().map(FileDTO::getUrl).collect(Collectors.toList()); |
|
|
|
List<String> imageList = formDTO.getImageList().stream().map(NoticeFileDTO::getUrl).collect(Collectors.toList()); |
|
|
|
safetyCheck(wordList, imageList); |
|
|
|
|
|
|
|
//3.查询组成员列表数据
|
|
|
@ -346,7 +342,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
} |
|
|
|
|
|
|
|
//6.通知已读未读消息表数据先删后增
|
|
|
|
noticeReafdRecordDao.delByNoticeId(formDTO.getNoticeId()); |
|
|
|
noticeReadRecordDao.delByNoticeId(formDTO.getNoticeId()); |
|
|
|
List<NoticeReadRecordEntity> reafdRecordList = new ArrayList<>(); |
|
|
|
memberList.forEach(m -> { |
|
|
|
NoticeReadRecordEntity reafdRecord = new NoticeReadRecordEntity(); |
|
|
@ -358,7 +354,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
if ("leader".equals(m.getGroupLeaderFlag())) { |
|
|
|
reafdRecord.setReadFlag(ReadFlagConstant.READ); |
|
|
|
}else { |
|
|
|
reafdRecord.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
reafdRecord.setReadFlag("un_read"); |
|
|
|
} |
|
|
|
reafdRecordList.add(reafdRecord); |
|
|
|
}); |
|
|
@ -370,7 +366,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
//7-1.获取小组信息
|
|
|
|
ResiGroupEntity groupEntity = resiGroupDao.selectById(entity.getGroupId()); |
|
|
|
if (null == groupEntity) { |
|
|
|
throw new RenException(String.format("保存小组通知,获取小组数据失败,小组Id->", tokenDto.getUserId())); |
|
|
|
throw new RenException(String.format("保存小组通知,获取小组数据失败,小组Id->", formDTO.getUserId())); |
|
|
|
} |
|
|
|
//7-2.推送站内信信息
|
|
|
|
List<UserMessageFormDTO> userMessageFormDTOS = new ArrayList<>(); |
|
|
@ -400,7 +396,7 @@ public class NoticeServiceImpl extends BaseServiceImpl<NoticeDao, NoticeEntity> |
|
|
|
* @Description 小组通知详情 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
public NoticeDetailResultDTO noticeDetail(TokenDto tokenDto, NoticeDetailFormDTO formDTO) { |
|
|
|
public NoticeDetailResultDTO noticeDetail(NoticeDetailFormDTO formDTO) { |
|
|
|
NoticeDetailResultDTO resultDTO = new NoticeDetailResultDTO(); |
|
|
|
List<NoticeDetailResultDTO.File> imageList = new ArrayList<>(); |
|
|
|
List<NoticeDetailResultDTO.File> docList = new ArrayList<>(); |
|
|
|