文档库推送信息处理

This commit is contained in:
wangchengjun
2022-03-24 13:28:40 +08:00
parent c12aa0538a
commit 7f9f448884
3 changed files with 47 additions and 30 deletions
@@ -1397,9 +1397,12 @@ public class SysUserController {
//获取当前组织下数据
List<SysDepartTreeModel> departTreeModelList = sysDepartService.queryTreeListByDepartId(departId);
if (StringUtils.isNotEmpty(departId)) {
List<String> departIds = new ArrayList<>();
departIds.add(departId);
List<SysUser> sysUserList = sysUserService.getUserListByDepIds(departIds);
String json = sysPushVO.getJson();
List<SysDepartUserTreeModel> allJson = JSONObject.parseArray(json, SysDepartUserTreeModel.class);
dealwithTree(departId, departTreeModelList, allJson);
dealwithTree(departId, departTreeModelList, allJson,sysUserList);
result.setResult(allJson);
} else {
List<SysDepartUserTreeModel> departUserTreeModelList = new ArrayList<>();
@@ -1441,8 +1444,12 @@ public class SysUserController {
* @param departId 当前选中组织ID
* @param departTreeModelList 当前组织下数据
* @param json 其他组织数据
* @param sysUserList 用户信息
*/
private void dealwithTree(String departId, List<SysDepartTreeModel> departTreeModelList, List<SysDepartUserTreeModel> json) {
private void dealwithTree(String departId,
List<SysDepartTreeModel> departTreeModelList,
List<SysDepartUserTreeModel> json,
List<SysUser> sysUserList) {
for (SysDepartUserTreeModel sysDepartUserTreeModel : json) {
String id = sysDepartUserTreeModel.getId();
if (id.equals(departId)) {
@@ -1453,6 +1460,19 @@ public class SysUserController {
BeanUtils.copyProperties(sysDepartTreeModel, target);
treeList.add(target);
}
if(CollectionUtils.isNotEmpty(sysUserList)){
for (SysUser sysUser : sysUserList) {
//复制
SysDepartUserTreeModel target = new SysDepartUserTreeModel();
BeanUtils.copyProperties(sysUser, target);
target.setKey(sysUser.getId());
target.setTitle(sysUser.getRealname()+"("+sysUser.getUsername()+")");
target.setChildren(null);
target.setIsLeaf(true);
treeList.add(target);
}
}
sysDepartUserTreeModel.setChildren(treeList);
break;
@@ -1460,7 +1480,7 @@ public class SysUserController {
List<SysDepartUserTreeModel> children = sysDepartUserTreeModel.getChildren();
if (CollectionUtils.isNotEmpty(children)) {
//复制
dealwithTree(departId, departTreeModelList, children);
dealwithTree(departId, departTreeModelList, children,sysUserList);
}
}
}
@@ -69,18 +69,6 @@
</if>
</select>
<select id="getUserListByDepIds" resultType="com.jero.modules.system.entity.SysUser">
select * from sys_user where del_flag = 0
<if test="departIds!=null and departIds.size()>0">
and id in (select dru.user_id from sys_depart_role dr, sys_depart_role_user dru where dr.id = dru.drole_id and dr.depart_id in
<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
)
</if>
</select>
<!-- 根据角色Id查询 -->
<select id="getUserByRoleId" resultType="com.jero.modules.system.entity.SysUser">
select * from sys_user where del_flag = 0 and id in (select user_id from sys_user_role where role_id=#{roleId})
@@ -49,6 +49,7 @@ import com.jero.modules.system.entity.SysDictItem;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.mapper.SysUserMapper;
import com.jero.modules.system.service.ISysAnnouncementService;
import com.jero.modules.system.service.ISysDepartService;
import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import com.jero.modules.system.service.impl.SysDictItemServiceImpl;
@@ -94,16 +95,7 @@ import java.io.OutputStream;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;
@@ -143,6 +135,8 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
@Autowired
private ISysUserService sysUserService;
@Autowired
private ISysDepartService sysDepartService;
@Autowired
private JeroElasticsearchTemplate jeroElasticsearchTemplate;
@Resource
private WebSocket webSocket;
@@ -2995,24 +2989,39 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
// if(StringUtils.isBlank(documentIds)){
// return "请选择文档";
// }
Set<String> allDepartIds = new HashSet<>();
//查询当前部门下所有部门
if(StringUtils.isNotEmpty(departIds)){
String[] departIdArr = departIds.split(",");
for (String departId : departIdArr) {
List<String> subDepIdsByDepId = sysDepartService.getSubDepIdsByDepId(departId);
allDepartIds.addAll(subDepIdsByDepId);
}
}
List<String> userIdList = new ArrayList<>();
List<String> thirdIdList = new ArrayList<>();
if (StringUtils.isNotBlank(departIds)) {
//查询部门下的人员
List<SysUser> userList = sysUserService.getUserListByDepIds(Arrays.asList(departIds.split(",")));
List<SysUser> userList = sysUserService.getUserListByDepIds(new ArrayList<>(allDepartIds));
if (userList.size() != 0) {
userIdList = userList.stream().map(SysUser::getId).collect(Collectors.toList());
thirdIdList = userList.stream().map(SysUser::getThirdId).collect(Collectors.toList());
userIdList = userList.stream().map(SysUser::getId).distinct().collect(Collectors.toList());
thirdIdList = userList.stream().map(SysUser::getThirdId).distinct().collect(Collectors.toList());
}
}
userIdList.addAll(Arrays.asList(userIds.split(",")));
// userIdList.addAll(Arrays.asList(userIds.split(",")));
//查询文档
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(documentIds);
List<String> serialNumberList = new ArrayList<>();
List<String> hrefList = new ArrayList<>();
for (Map<String, Object> map : mapList) {
serialNumberList.add((String) map.get("serial_number"));
// String href = "<a href='/docManage/library/detail?id:" + idTemp +
// "&title:" + title +
// "&serial_number:" + serialNumber + "'" + " target='_blank'>" + serialNumber + "</a>";
String href = "<a href='/docManage/library/detail?id:" + (String) map.get("id") +
"&title:" + (String) map.get("title") +
"&serial_number:" + (String) map.get("serial_number") + "'" + " target='_blank'>" + (String) map.get("serial_number") + "</a>,";
@@ -3022,7 +3031,7 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String content = sysUser.getRealname() + "向内推送了" + StringUtils.join(serialNumberList, ",") + ",请注意查看。";
String contentInfo = sysUser.getRealname() + "向内推送了" + StringUtils.join(serialNumberList, ",") + ",请注意查看。";
String contentInfo = sysUser.getRealname() + "向内推送了" + StringUtils.join(hrefList, ",") + ",请注意查看。";
//封装消息的实体类
SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, content, contentInfo);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);