This commit is contained in:
hanjian 2024-09-08 20:32:22 +08:00
parent 5607c957fb
commit b69682c2d0
6 changed files with 76 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import com.blueland.bpmclient.model.*;
import com.rzdata.common.core.controller.BaseController;
import com.rzdata.common.core.domain.AjaxResult;
import com.rzdata.common.core.domain.entity.SysUser;
import com.rzdata.common.core.domain.model.LoginUser;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.common.utils.StringUtils;
import com.rzdata.system.service.ISysConfigService;
@ -616,4 +617,18 @@ public class WorkflowController extends BaseController {
public AjaxResult getRecordbyPorcInstId(@PathVariable String procInstId) throws Exception{
return AjaxResult.success(workflowService.getRecordbyPorcInstId(procInstId));
}
/**
* 获取用户的消息数量代办/消息中心
*/
@GetMapping("/msg/count")
public AjaxResult msgCount() {
AjaxResult ajax = AjaxResult.success();
LoginUser loginUser = getLoginUser();
Map<String, Object> resultMap = workflowService.selectUserMsgCount(loginUser.getUser());
ajax.put("msgCount", resultMap.get("msgCount"));
ajax.put("taskCount", resultMap.get("taskCount"));
ajax.put("totalMsgCount", resultMap.get("totalMsgCount"));
return ajax;
}
}

View File

@ -8,6 +8,7 @@ import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.blueland.bpmclient.BpmClient;
import com.blueland.bpmclient.model.*;
import com.google.common.collect.Maps;
import com.rzdata.common.core.domain.entity.SysUser;
import com.rzdata.common.utils.SecurityUtils;
import com.rzdata.common.utils.StringUtils;
@ -54,6 +55,10 @@ public class WorkflowService {
@Autowired
IWorkflowLogService iWorkflowLogService;
@Autowired
private ITzMessageService tzMessageService;
private final static String CUR_ACT_DEF_KEY = "curActDef";
private final static String CUR_ACT_INST_KEY = "curActInst";
private final static String PROC_INST_KEY = "procInst";
@ -790,4 +795,32 @@ public class WorkflowService {
String url = String.format("%s/%s?procInstId=%s", bpmcConfig.getServiceUrl(), workflowConfig.getRecordQueryUrl(), porcInstId);
return JSONArray.parseArray(getBpmClient().get(url));
}
public Map<String, Object> selectUserMsgCount(SysUser user) {
Map<String, Object> resultMap = Maps.newHashMap();
int totalMsgCount = 0;
int msgCount = 0;
int taskCount = 0;
try {
msgCount = tzMessageService.selectTzMessageByUserCount(String.valueOf(user.getUserId()));
totalMsgCount = msgCount;
resultMap.put("msgCount", msgCount);
} catch (Exception e){
log.error("查询消息中心未读消息数量异常", e);
}
try {
SearchQuery searchQuery = new SearchQuery();
searchQuery.setRecUserId(user.getUserName());
searchQuery.setStatus(1);
Map<String, Integer> resultRecordCount = getRecordCount(searchQuery);
taskCount = resultRecordCount.get("count");
totalMsgCount += taskCount;
} catch (Exception e){
log.error("查询待办消息数量异常", e);
}
resultMap.put("msgCount", msgCount);
resultMap.put("taskCount", taskCount);
resultMap.put("totalMsgCount", totalMsgCount);
return resultMap;
}
}

View File

@ -37,6 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessType != null and businessType != ''"> and business_type = #{businessType}</if>
and deleted = '0'
</where>
order by create_time desc
</select>
<select id="selectTzMessageById" parameterType="String" resultMap="TzMessageResult">

View File

@ -31,6 +31,8 @@ public class SysDept extends BaseEntity
/** 部门名称 */
private String deptName;
private String deptType;
/** 显示顺序 */
private Integer orderNum;
@ -97,6 +99,16 @@ public class SysDept extends BaseEntity
this.deptName = deptName;
}
public String getDeptType()
{
return deptType;
}
public void setDeptType(String deptType)
{
this.deptType = deptType;
}
@NotNull(message = "显示顺序不能为空")
public Integer getOrderNum()
{

View File

@ -1,6 +1,7 @@
package com.rzdata.system.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
@ -217,9 +218,18 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
handleDeptType(dept);
return deptMapper.insertDept(dept);
}
private void handleDeptType(SysDept dept){
String ancestors = dept.getAncestors();
List<String> ancestorList = Arrays.asList(ancestors.split(","));
List<String> ancestorFilterList = ancestorList.stream().filter(e ->
!"0".equals(e)).collect(Collectors.toList());
dept.setDeptType(String.valueOf(ancestorFilterList.size()));
}
/**
* 修改保存部门信息
*

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
<result property="deptType" column="dept_type" />
<result property="orderNum" column="order_num" />
<result property="leader" column="leader" />
<result property="phone" column="phone" />
@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_type, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
@ -92,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="deptType != null and deptType != ''">dept_type,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
@ -104,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="deptType != null and deptType != ''">#{deptType},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
@ -120,6 +123,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="deptType != null and deptType != ''">dept_type = #{deptType},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>