|
|
@@ -12,10 +12,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.xunmei.common.core.constant.ErrorMsgConstants;
|
|
|
import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotification;
|
|
|
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToOrg;
|
|
|
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToRole;
|
|
|
-import com.xunmei.common.core.domain.message.domain.CoreAnnouncementNotificationToUser;
|
|
|
+import com.xunmei.common.core.domain.message.domain.*;
|
|
|
import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationAppPageDto;
|
|
|
import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationDto;
|
|
|
import com.xunmei.common.core.domain.message.dto.CoreAnnouncementNotificationPageDto;
|
|
|
@@ -167,10 +164,12 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
private Page<CoreAnnouncementNotificationPageVo> getOrgAndRoleListMap(Page<CoreAnnouncementNotificationPageVo> page) {
|
|
|
List<CoreAnnouncementNotificationPageVo> records = page.getRecords();
|
|
|
List<CoreAnnouncementNotificationToOrg> notificationToOrgs = coreAnnouncementNotificationMapper.selectOrgIds(records);
|
|
|
- List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
|
|
|
+ //List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
|
|
|
+ List<CoreAnnouncementNotificationToOrgtype> notificationToOrgtypes = coreAnnouncementNotificationMapper.selectOrgtypeIds(records);
|
|
|
for(CoreAnnouncementNotificationPageVo record : records){
|
|
|
record.setTagOrgIds(notificationToOrgs.stream().filter(org -> org.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToOrg::getOrgId).collect(Collectors.toList()));
|
|
|
- record.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
|
|
|
+ record.setTagOrgTypes(notificationToOrgtypes.stream().filter(orgtype -> orgtype.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToOrgtype::getOrgType).collect(Collectors.toList()));
|
|
|
+ // record.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(record.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
|
|
|
}
|
|
|
return page;
|
|
|
}
|
|
|
@@ -191,9 +190,12 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
List<CoreAnnouncementNotificationPageVo> records = new ArrayList<>();
|
|
|
records.add(vo);
|
|
|
List<CoreAnnouncementNotificationToOrg> notificationToOrgs = coreAnnouncementNotificationMapper.selectOrgIds(records);
|
|
|
- List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
|
|
|
+ List<CoreAnnouncementNotificationToOrgtype> notificationToOrgtypes = coreAnnouncementNotificationMapper.selectOrgtypeIds(records);
|
|
|
+
|
|
|
+ // List<CoreAnnouncementNotificationToRole> notificationToRoles = coreAnnouncementNotificationMapper.selectRoleIds(records);
|
|
|
vo.setTagOrgIds(notificationToOrgs.stream().filter(org -> org.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToOrg::getOrgId).collect(Collectors.toList()));
|
|
|
- vo.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
|
|
|
+ vo.setTagOrgTypes(notificationToOrgtypes.stream().filter(org -> org.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToOrgtype::getOrgType).collect(Collectors.toList()));
|
|
|
+ //vo.setTagRoleIds(notificationToRoles.stream().filter(role -> role.getAnnouncementNotificationId().equals(vo.getId())).map(CoreAnnouncementNotificationToRole::getRoleId).collect(Collectors.toList()));
|
|
|
return vo;
|
|
|
}
|
|
|
|
|
|
@@ -217,8 +219,18 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void insertCoreAnnouncementNotification(CoreAnnouncementNotificationDto request) {
|
|
|
- List<Long> orgIds = request.getTagOrgIds();
|
|
|
- List<Long> roleIds = request.getTagRoleIds();
|
|
|
+ List<Long> orgIds = new ArrayList<>();
|
|
|
+ /* List<Long> roleIds = request.getTagRoleIds();*/
|
|
|
+ List<String> orgTypes = request.getTagOrgTypes();
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectSysOrgById(request.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ List<SysOrg> orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.findAllOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ //获取机构创建机构下的指定类型的机构
|
|
|
+ List<SysOrg> orgLists = orgList.stream().filter(r->(r.getType()!=null&&orgTypes.contains(r.getType().toString()))&&(r.getPath()!=null&&r.getPath().contains(sysOrg.getPath()))).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isEmpty(orgLists)){
|
|
|
+ throw new RuntimeException("没有指定机构类型的机构");
|
|
|
+ }else{
|
|
|
+ orgLists.forEach(r->{orgIds.add(r.getId());});
|
|
|
+ }
|
|
|
CoreAnnouncementNotification notification = this.buildSaveObject(request);
|
|
|
if(CollectionUtil.isNotEmpty(orgIds)){
|
|
|
List<CoreAnnouncementNotificationToOrg> list = new ArrayList<>();
|
|
|
@@ -230,7 +242,19 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
});
|
|
|
coreAnnouncementNotificationMapper.insertBatchToOrg(list);
|
|
|
}
|
|
|
- if(CollectionUtil.isNotEmpty(roleIds)){
|
|
|
+ if(CollectionUtil.isNotEmpty(orgTypes)){
|
|
|
+ List<CoreAnnouncementNotificationToOrgtype> list = new ArrayList<>();
|
|
|
+ orgTypes.forEach(type -> {
|
|
|
+ CoreAnnouncementNotificationToOrgtype orgtype = new CoreAnnouncementNotificationToOrgtype();
|
|
|
+ orgtype.setOrgType(type);
|
|
|
+ orgtype.setAnnouncementNotificationId(notification.getId());
|
|
|
+ list.add(orgtype);
|
|
|
+ });
|
|
|
+ coreAnnouncementNotificationMapper.insertBatchToOrgType(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /* if(CollectionUtil.isNotEmpty(roleIds)){
|
|
|
List<CoreAnnouncementNotificationToRole> list = new ArrayList<>();
|
|
|
roleIds.forEach(roleId -> {
|
|
|
CoreAnnouncementNotificationToRole toOrg = new CoreAnnouncementNotificationToRole();
|
|
|
@@ -239,7 +263,7 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
list.add(toOrg);
|
|
|
});
|
|
|
coreAnnouncementNotificationMapper.insertBatchToRole(list);
|
|
|
- }
|
|
|
+ }*/
|
|
|
coreAnnouncementNotificationMapper.insert(notification);
|
|
|
}
|
|
|
|
|
|
@@ -266,11 +290,19 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public void updateCoreAnnouncementNotification(CoreAnnouncementNotificationDto request) {
|
|
|
- List<Long> orgIds = request.getTagOrgIds();
|
|
|
- List<Long> roleIds = request.getTagRoleIds();
|
|
|
- //删除公告通知与角色和机构的关系
|
|
|
- coreAnnouncementNotificationMapper.deleteRole(request.getId());
|
|
|
+ List<Long> orgIds = new ArrayList<>();
|
|
|
+ List<String> orgTypes = request.getTagOrgTypes();
|
|
|
+ SysOrg sysOrg = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.selectSysOrgById(request.getOrgId(), SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ List<SysOrg> orgList = RemoteCallHandlerExecutor.executeRemoteCall(() -> orgService.findAllOrg(SecurityConstants.INNER), ErrorMsgConstants.QUERY_ORG_DATA_ERROR);
|
|
|
+ //获取机构创建机构下的指定类型的机构
|
|
|
+ List<SysOrg> orgLists = orgList.stream().filter(r->(r.getType()!=null&&orgTypes.contains(r.getType().toString()))&&(r.getPath()!=null&&r.getPath().contains(sysOrg.getPath()))).collect(Collectors.toList());
|
|
|
+ if(CollectionUtil.isEmpty(orgLists)){
|
|
|
+ throw new RuntimeException("没有指定机构类型的机构");
|
|
|
+ }else{
|
|
|
+ orgLists.forEach(r->{orgIds.add(r.getId());});
|
|
|
+ }
|
|
|
coreAnnouncementNotificationMapper.deleteOrg(request.getId());
|
|
|
+ coreAnnouncementNotificationMapper.deleteOrgtype(request.getId());
|
|
|
CoreAnnouncementNotification notification = this.buildSaveObject(request);
|
|
|
if(CollectionUtil.isNotEmpty(orgIds)){
|
|
|
List<CoreAnnouncementNotificationToOrg> list = new ArrayList<>();
|
|
|
@@ -282,7 +314,18 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
});
|
|
|
coreAnnouncementNotificationMapper.insertBatchToOrg(list);
|
|
|
}
|
|
|
- if(CollectionUtil.isNotEmpty(roleIds)){
|
|
|
+ if(CollectionUtil.isNotEmpty(orgTypes)){
|
|
|
+ List<CoreAnnouncementNotificationToOrgtype> list = new ArrayList<>();
|
|
|
+ orgTypes.forEach(type -> {
|
|
|
+ CoreAnnouncementNotificationToOrgtype orgtype = new CoreAnnouncementNotificationToOrgtype();
|
|
|
+ orgtype.setOrgType(type);
|
|
|
+ orgtype.setAnnouncementNotificationId(notification.getId());
|
|
|
+ list.add(orgtype);
|
|
|
+ });
|
|
|
+ coreAnnouncementNotificationMapper.insertBatchToOrgType(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /* if(CollectionUtil.isNotEmpty(roleIds)){
|
|
|
List<CoreAnnouncementNotificationToRole> list = new ArrayList<>();
|
|
|
roleIds.forEach(roleId -> {
|
|
|
CoreAnnouncementNotificationToRole toOrg = new CoreAnnouncementNotificationToRole();
|
|
|
@@ -291,7 +334,7 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
list.add(toOrg);
|
|
|
});
|
|
|
coreAnnouncementNotificationMapper.insertBatchToRole(list);
|
|
|
- }
|
|
|
+ }*/
|
|
|
coreAnnouncementNotificationMapper.updateById(notification);
|
|
|
}
|
|
|
|
|
|
@@ -307,8 +350,9 @@ public class CoreAnnouncementNotificationServiceImpl extends ServiceImpl<CoreAnn
|
|
|
//删除公告通知与角色和机构的关系
|
|
|
//刪除已读记录
|
|
|
for(Long id:ids){
|
|
|
- coreAnnouncementNotificationMapper.deleteRole(id);
|
|
|
+ // coreAnnouncementNotificationMapper.deleteRole(id);
|
|
|
coreAnnouncementNotificationMapper.deleteOrg(id);
|
|
|
+ coreAnnouncementNotificationMapper.deleteOrgtype(id);
|
|
|
coreAnnouncementNotificationMapper.deleteNotificationToUsers(id);
|
|
|
}
|
|
|
|