根据申请填写的部门动态分配流程审批人

This commit is contained in:
wangliwen 2022-04-20 15:05:19 +08:00
parent 004537b865
commit cc1778e40b
16 changed files with 492 additions and 409 deletions

View File

@ -22,6 +22,8 @@ import org.activiti.engine.task.Task;
import org.activiti.image.ProcessDiagramGenerator; import org.activiti.image.ProcessDiagramGenerator;
import org.activiti.spring.ProcessEngineFactoryBean; import org.activiti.spring.ProcessEngineFactoryBean;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -41,6 +43,7 @@ import java.util.Map;
*/ */
@Service @Service
public class ActHistoryService { public class ActHistoryService {
private static Logger logger = LoggerFactory.getLogger(ActHistoryService.class);
@Autowired @Autowired
protected RepositoryService repositoryService; protected RepositoryService repositoryService;
@ -64,7 +67,6 @@ public class ActHistoryService {
private SysUserService sysUserService; private SysUserService sysUserService;
public void getProcessInstanceDiagram(String processInstanceId, HttpServletResponse response) throws Exception { public void getProcessInstanceDiagram(String processInstanceId, HttpServletResponse response) throws Exception {
if (StringUtils.isEmpty(processInstanceId)) { if (StringUtils.isEmpty(processInstanceId)) {
return; return;
@ -102,8 +104,10 @@ public class ActHistoryService {
ImageIO.write(bufferedImage, "png", response.getOutputStream()); ImageIO.write(bufferedImage, "png", response.getOutputStream());
} }
/** /**
* 获取需要高亮的线 * 获取需要高亮的线
*
* @param processDefinitionEntity * @param processDefinitionEntity
* @param historicActivityInstances * @param historicActivityInstances
* @return * @return
@ -170,6 +174,7 @@ public class ActHistoryService {
query.processDefinitionId((String) params.get("processDefinitionId")); query.processDefinitionId((String) params.get("processDefinitionId"));
} }
if (StringUtils.isNotEmpty((String) params.get("ended"))) { if (StringUtils.isNotEmpty((String) params.get("ended"))) {
logger.info("ended参数值为" + (String) params.get("ended"));
if ("true".equals((String) params.get("ended"))) { if ("true".equals((String) params.get("ended"))) {
query.finished(); query.finished();
} else if ("false".equals((String) params.get("ended"))) { } else if ("false".equals((String) params.get("ended"))) {
@ -226,6 +231,7 @@ public class ActHistoryService {
/** /**
* 我发起的流程 * 我发起的流程
* 根据登录用户信息获取处理中的示例和任务信息 * 根据登录用户信息获取处理中的示例和任务信息
*
* @param params * @param params
* @return * @return
*/ */
@ -255,6 +261,7 @@ public class ActHistoryService {
/** /**
* 转换Task对象 * 转换Task对象
*
* @param task * @param task
* @param dto * @param dto
*/ */

View File

@ -3,6 +3,10 @@ package io.renren.modules.processForm.listener;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO; import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dto.SysDeptDTO;
import io.renren.modules.sys.dto.SysRoleDTO;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRoleService; import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysRoleUserService; import io.renren.modules.sys.service.SysRoleUserService;
import io.renren.modules.sys.service.SysUserService; import io.renren.modules.sys.service.SysUserService;
@ -21,6 +25,8 @@ import java.util.Map;
public class CorrectionListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate { public class CorrectionListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
private static Logger logger = LoggerFactory.getLogger(CorrectionListener.class); private static Logger logger = LoggerFactory.getLogger(CorrectionListener.class);
private static String roleName = "部门审批人";
@Autowired @Autowired
private SysRoleService sysRoleService; private SysRoleService sysRoleService;
@Autowired @Autowired
@ -29,23 +35,28 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
private SysUserService sysUserService; private SysUserService sysUserService;
@Autowired @Autowired
private SysRoleUserService sysRoleUserService; private SysRoleUserService sysRoleUserService;
@Autowired
private SysDeptService sysDeptService;
@Override @Override
public void notify(DelegateTask delegateTask) { public void notify(DelegateTask delegateTask) {
logger.info("进入DelegateTask");
logger.info("EventName:" + delegateTask.getEventName());
logger.info("Owner:" + delegateTask.getOwner());
Map<String, Object> kv = delegateTask.getVariables(); Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson(); Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv); JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class); TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
logger.info(abilityApplicationDTO.toString()); logger.info(abilityApplicationDTO.toString());
abilityApplicationDTO.getUnit(); SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit());
logger.info("deptDTOId:" + deptDTO.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.info("roleDTOId:" + roleDTO.getId());
delegateTask.setAssignee("1513432847327199233"); delegateTask.setAssignee("1513432847327199233");
String taskKey = delegateTask.getTaskDefinitionKey(); SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
taskService.setAssignee(delegateTask.getId(), "1516307964617076737"); if (userDTO != null) {
String processDefinitionId = delegateTask.getProcessDefinitionId(); logger.info("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
} else {
logger.info("未查到该部门对应 " + roleName);
}
} }
@Override @Override

View File

@ -29,4 +29,11 @@ public interface SysDeptDao extends BaseDao<SysDeptEntity> {
*/ */
List<Long> getSubDeptIdList(String id); List<Long> getSubDeptIdList(String id);
/**
* 根据名称获取部门所有信息
* @param name
* @return
*/
SysDeptEntity getByName(String name);
} }

View File

@ -6,10 +6,9 @@ import org.apache.ibatis.annotations.Mapper;
/** /**
* 角色管理 * 角色管理
*
*/ */
@Mapper @Mapper
public interface SysRoleDao extends BaseDao<SysRoleEntity> { public interface SysRoleDao extends BaseDao<SysRoleEntity> {
SysRoleEntity getByName(String name);
} }

View File

@ -10,7 +10,6 @@ import java.util.Map;
/** /**
* 系统用户 * 系统用户
*
*/ */
@Mapper @Mapper
public interface SysUserDao extends BaseDao<SysUserEntity> { public interface SysUserDao extends BaseDao<SysUserEntity> {
@ -32,4 +31,12 @@ public interface SysUserDao extends BaseDao<SysUserEntity> {
* 根据部门ID,查询用户ID列表 * 根据部门ID,查询用户ID列表
*/ */
List<Long> getUserIdListByDeptId(List<Long> deptIdList); List<Long> getUserIdListByDeptId(List<Long> deptIdList);
/**
* 获取该部门拥有该权限的用户信息
* @param deptId
* @param roleId
* @return
*/
SysUserEntity getByDeptIdAndRoleId(@Param("deptId") Long deptId, @Param("roleId") Long roleId);
} }

View File

@ -28,4 +28,6 @@ public interface SysDeptService extends BaseService<SysDeptEntity> {
* @param id 部门ID * @param id 部门ID
*/ */
List<Long> getSubDeptIdList(Long id); List<Long> getSubDeptIdList(Long id);
SysDeptDTO getByName(String name);
} }

View File

@ -28,4 +28,6 @@ public interface SysRoleService extends BaseService<SysRoleEntity> {
void delete(Long[] ids); void delete(Long[] ids);
SysRoleDTO getByName(String name);
} }

View File

@ -11,7 +11,6 @@ import java.util.Map;
/** /**
* 系统用户 * 系统用户
*
*/ */
public interface SysUserService extends BaseService<SysUserEntity> { public interface SysUserService extends BaseService<SysUserEntity> {
@ -31,6 +30,7 @@ public interface SysUserService extends BaseService<SysUserEntity> {
/** /**
* 修改密码 * 修改密码
*
* @param id 用户ID * @param id 用户ID
* @param newPassword 新密码 * @param newPassword 新密码
*/ */
@ -46,4 +46,6 @@ public interface SysUserService extends BaseService<SysUserEntity> {
*/ */
List<Long> getUserIdListByDeptId(List<Long> deptIdList); List<Long> getUserIdListByDeptId(List<Long> deptIdList);
SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId);
} }

View File

@ -111,8 +111,18 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptDao, SysDeptEntit
return deptIdList; return deptIdList;
} }
@Override
public SysDeptDTO getByName(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}
SysDeptEntity entity = baseDao.getByName(name);
return ConvertUtils.sourceToTarget(entity, SysDeptDTO.class);
}
/** /**
* 获取所有上级部门ID * 获取所有上级部门ID
*
* @param pid 上级ID * @param pid 上级ID
*/ */
private String getPidList(Long pid) { private String getPidList(Long pid) {

View File

@ -24,7 +24,6 @@ import java.util.Map;
/** /**
* 角色 * 角色
*
*/ */
@Service @Service
public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService { public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntity> implements SysRoleService {
@ -123,4 +122,12 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit
sysRoleDataScopeService.deleteByRoleIds(ids); sysRoleDataScopeService.deleteByRoleIds(ids);
} }
@Override
public SysRoleDTO getByName(String name) {
if (StringUtils.isEmpty(name)) {
return null;
}
return ConvertUtils.sourceToTarget(baseDao.getByName(name), SysRoleDTO.class);
}
} }

View File

@ -28,7 +28,6 @@ import java.util.Map;
/** /**
* 系统用户 * 系统用户
*
*/ */
@Service @Service
public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntity> implements SysUserService { public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntity> implements SysUserService {
@ -159,4 +158,13 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
return baseDao.getUserIdListByDeptId(deptIdList); return baseDao.getUserIdListByDeptId(deptIdList);
} }
@Override
public SysUserDTO getByDeptIdAndRoleId(Long deptId, Long roleId) {
if (roleId == null) {
return null;
}
SysUserEntity entity = baseDao.getByDeptIdAndRoleId(deptId, roleId);
return ConvertUtils.sourceToTarget(entity, SysUserDTO.class);
}
} }

View File

@ -32,3 +32,6 @@ spring:
wall: wall:
config: config:
multi-statement-allow: true multi-statement-allow: true
resource:
root_url: 15.2.21.238
path: /home/yth/files/

View File

@ -1,7 +1,7 @@
#上传的静态资源配置 #上传的静态资源配置
resource: resource:
root_url: 127.0.0.1 root_url: 15.2.21.238
path: E:\liwen\ path: /home/yth/files/
# Tomcat # Tomcat
server: server:
tomcat: tomcat:

View File

@ -29,4 +29,9 @@
select id from sys_dept where pids like #{id} select id from sys_dept where pids like #{id}
</select> </select>
<select id="getByName" resultType="io.renren.modules.sys.entity.SysDeptEntity">
select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1
where t1.name = #{name}
</select>
</mapper> </mapper>

View File

@ -3,5 +3,7 @@
<mapper namespace="io.renren.modules.sys.dao.SysRoleDao"> <mapper namespace="io.renren.modules.sys.dao.SysRoleDao">
<select id="getByName" resultType="io.renren.modules.sys.entity.SysRoleEntity">
SELECT * FROM sys_role WHERE `name` = #{name}
</select>
</mapper> </mapper>

View File

@ -50,4 +50,15 @@
</foreach> </foreach>
</select> </select>
<select id="getByDeptIdAndRoleId" resultType="io.renren.modules.sys.entity.SysUserEntity">
SELECT t2.*,( SELECT t3.NAME FROM sys_dept t3 WHERE t3.id = t2.dept_id )
FROM
sys_role_user t1,
sys_user t2
WHERE
t2.id = t1.user_id
AND t1.role_id = #{roleId}
AND t2.dept_id = #{deptId}
</select>
</mapper> </mapper>