From 2087f9ef34589091605c1d310db6c27b3da6c88a Mon Sep 17 00:00:00 2001 From: zhn <947514737@qq.com> Date: Tue, 7 Jun 2022 15:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BussDocumentLibraryEOServiceImpl.java | 113 +++++++++++++----- 1 file changed, 81 insertions(+), 32 deletions(-) diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java index e43a59a54..b2ec35696 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/service/impl/BussDocumentLibraryEOServiceImpl.java @@ -36,7 +36,9 @@ import com.jero.modules.document.service.IBussDocumentLibraryEOService; import com.jero.modules.document.utils.ReadPdfUtil; import com.jero.modules.document.utils.ReadWordUtil; import com.jero.modules.document.vo.QueryConditionVO; +import com.jero.modules.domain.entity.DomainUserRel; import com.jero.modules.domain.service.DomainUserRelService; +import com.jero.modules.domain.service.impl.DomainManageServiceImpl; import com.jero.modules.feishu.service.IFeishuService; import com.jero.modules.home.entity.HomeDocumentDynamicEO; import com.jero.modules.home.service.IHomeDocumentDynamicEOService; @@ -50,6 +52,7 @@ import com.jero.modules.split.common.FileUnZip; import com.jero.modules.split.entity.SarFileSplitInfoEO; import com.jero.modules.split.service.ISarFileSplitInfoService; import com.jero.modules.subscribe.entity.OnlCgformSubscribe; +import com.jero.modules.subscribe.mapper.OnlCgformSubscribeMapper; import com.jero.modules.subscribe.service.IOnlCgformSubscribeService; import com.jero.modules.system.entity.SysAnnouncement; import com.jero.modules.system.entity.SysCategory; @@ -171,6 +174,10 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl fieldFileList, List fieldPullList, String cut) { + String technologyTerritoryNew = (String) dataList.get(0).get("technology_territory"); //1. 处理订阅的发送消息 //修改的内容 String flag ="1";//消息的标识(英文) StringBuilder sb = getUpdateInfo(map, dataList, fieldList, fieldDateList, fieldFileList, fieldPullList, null,flag); + //树形数据字典 + List categoryList = sysCategoryService.list(); String sbStr = ""; if (ObjectUtils.isNotEmpty(sb)) { sbStr = sb.substring(0, sb.length() - 1); @@ -2991,55 +3001,94 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImplXXX对“GB 7258 进行了修改请及时查看”) //向订阅领域管理中订阅了该技术领域的人和文档库中订阅了该条文档的人发送消息 Map mapTemp = new HashMap<>(); mapTemp.put("domainId", map.get("technology_territory")); mapTemp.put("documentId", map.get("id")); //订阅技术领域的人和订阅该条标准的人 - List userIdList = domainUserRelService.queryDomainUserRelInfo(mapTemp); - if(CollectionUtils.isNotEmpty(userIdList)){ - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SysUser::getId,userIdList); - List sysUserList = sysUserService.list(wrapper); - sysUserList = sysUserList.stream().filter(e->StringUtils.isNotBlank(e.getThirdId())).collect(Collectors.toList()); - List thirdIdList = sysUserList.stream().map(SysUser::getThirdId).collect(Collectors.toList()); +// List userIdList = domainUserRelService.queryDomainUserRelInfo(mapTemp); + //订阅技术领域发消息 + List domainUserRelList = domainManageService.list(); + List thirdIdList = new ArrayList<>(); + String technologyTerritoryNameEn = ""; + if(StringUtils.isNotBlank(technologyTerritory) && !technologyTerritory.equals(technologyTerritoryNew) && domainUserRelList.size() != 0){ + List collect = domainUserRelList.stream() + .filter(e -> technologyTerritory.contains(e.getDomainId())) + .collect(Collectors.toList()); + if(collect.size() != 0){ + List userIdList = collect.stream().map(DomainUserRel::getUserId).collect(Collectors.toList()); + List domainIdList = collect.stream().map(DomainUserRel::getDomainId).distinct().collect(Collectors.toList()); + if(userIdList.size() != 0){ + List sysUsersFeishu = this.sysUserMapper.selectBatchIds(userIdList); + if(sysUsersFeishu.size() != 0){ + thirdIdList = sysUsersFeishu.stream().map(SysUser::getThirdId).collect(Collectors.toList()); + } + } + if(domainIdList.size() != 0){ + StringBuilder sbTemp = new StringBuilder(); + for (String s : domainIdList) { + List collect1 = categoryList.stream().filter(e -> s.equals(e.getId())).collect(Collectors.toList()); + if(collect1.size() != 0){ + String enName = collect1.get(0).getEnName().trim(); + sbTemp.append(enName + ","); + } + } + if(StringUtils.isNotBlank(sbTemp)){ + technologyTerritoryNameEn = sbTemp.substring(0, sbTemp.length() - 1); + } - String id = (String) map.get("id"); + } + } + } + //订阅标准 + List userIdListUpdate = new ArrayList<>(); + String id = (String) map.get("id"); + if (StringUtils.isNotBlank(id)) { + QueryWrapper querySubscribe = new QueryWrapper<>(); + querySubscribe.lambda().eq(OnlCgformSubscribe::getDocumentId, id); + List onlCgformSubscribeList = onlCgformSubscribeMapper.selectList(querySubscribe); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(onlCgformSubscribeList)) { + List userNameList = onlCgformSubscribeList.stream().map(OnlCgformSubscribe::getCreateBy).distinct().collect(Collectors.toList()); + + QueryWrapper userQuery = new QueryWrapper<>(); + userQuery.lambda().in(SysUser::getUsername, userNameList); + List sysUsers = this.sysUserMapper.selectList(userQuery); + if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(sysUsers)) { + userIdListUpdate = sysUsers.stream().map(SysUser::getId).collect(Collectors.toList()); + } + } + } + + //飞书消息 + if(thirdIdList.size() != 0){ + try { + String contentInfoFei = "In the " + technologyTerritoryNameEn + " technical field you subscribed to, the " + + category + " " + serialNumber+" has been updated."; + //跳转文档详情 + String url = backUrl + "/docManage/library/detail?id=" + id; + iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentInfoFei, MessageTypeEnum.READ.getName(), url); + } catch (IOException e) { + log.error("文档新增飞书消息推送失败"); + } + } + + //站内消息 + if(CollectionUtils.isNotEmpty(userIdListUpdate)){ String title = (String) map.get("title"); String href = "" + serialNumber + ""; - if (StringUtils.isNotBlank(sbStr.toString())) { //您订阅的XXX已被修改 String content = "In the "+serialNumber+" you subscribed to, has been modified,Please pay attention to check."; -// String content = sysUser.getUsername() + " update " + serialNumber + ",Please pay attention to check."; - //您订阅的GB 7258-2021 中,由张三将技术领域"车身"改为"车门" - - String contentInfo = "In the "+serialNumber+" you subscribed to, "+sysUser.getUsername()+" changed the "+ href+ sbStr.toString(); -// String contentInfo = sysUser.getUsername() + " update " + href + sbStr.toString(); + String contentInfo = "In the "+href+" you subscribed to, "+sysUser.getUsername()+" changed the "+ href + " " + sbStr.toString(); //封装消息的实体类 - SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, content, contentInfo); + SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdListUpdate, content, contentInfo); sysAnnouncementService.saveAnnouncement(sysAnnouncement); sendWebsocket((String) map.get("id"), contentInfo); } - //飞书 - try { - String hrefTemp = "" + serialNumber + ""; - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); - String replace = sbStr.replaceAll("", "").replaceAll("", ""); - String contentInfoFei = "In the " + category + serialNumber+" you subscribed to, "+sysUser.getUsername()+" changed the " + replace; - String contentInfo = "In the " + category + hrefTemp+" you subscribed to, "+sysUser.getUsername()+" changed the " + sbStr; - String content = "In the "+serialNumber+" you subscribed to, has been modified,Please pay attention to check."; - String encodeContent = UriEncoder.encode(content); - String encodeContentInfo = UriEncoder.encode(contentInfo); - String url = backUrl + "/system/MessageDetails?msgContent="+encodeContent+"&sendTime="+sdf.format(new Date())+"&msgContentInfo="+encodeContentInfo; - iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentInfoFei, MessageTypeEnum.READ.getName(), url); - } catch (IOException e) { - log.error("文档新增飞书消息推送失败"); - } } // } //2. 处理修改代替标准的发送消息(法规负责人)