区、市审批流程监听器完善

This commit is contained in:
Koi-tsk 2022-08-22 17:59:18 +08:00
parent d4c88b8d20
commit c5ab16e7f9
6 changed files with 87 additions and 36 deletions

View File

@ -1,15 +1,20 @@
package io.renren.modules.processForm.listener.v3;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dao.SysUserDao;
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.entity.SysRegionEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.enums.RegionLevelEnum;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.TaskService;
@ -22,8 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
import java.util.*;
/**
* 申请发起人区市管理员审批
@ -40,8 +44,12 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysRoleService sysRoleService;
@Value("${big_date.assignee_role_name}")
@Autowired
private SysRegionService sysRegionService;
@Value("${big_date.assignee_district_role_name}")
private String roleName; // 具备审批的角色名称
@Override
@ -62,7 +70,6 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
}
private void create(DelegateTask delegateTask) {
// TODO 暂时使用部门代替行政区
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
@ -73,15 +80,20 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
logger.error("deptDTOId:" + deptDTO.getId());
SysRegionEntity regionEntity =sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
if (userDTO != null) {
logger.error("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
assignee = null;

View File

@ -1,15 +1,20 @@
package io.renren.modules.processForm.listener.v3;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.sys.dao.SysUserDao;
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.entity.SysRegionEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.enums.RegionLevelEnum;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.TaskService;
@ -22,8 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
import java.util.*;
/**
* 市级区市管理员审批
@ -40,8 +44,12 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
@Autowired
private SysUserService sysUserService;
@Autowired
private SysUserDao sysUserDao;
@Autowired
private SysRoleService sysRoleService;
@Value("${big_date.assignee_role_name}")
@Autowired
private SysRegionService sysRegionService;
@Value("${big_date.assignee_city_role_name}")
private String roleName; // 具备审批的角色名称
@Override
@ -62,7 +70,6 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
}
private void create(DelegateTask delegateTask) {
// TODO 暂时使用部门代替市
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
@ -73,15 +80,20 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
logger.error("deptDTOId:" + deptDTO.getId());
SysRegionEntity regionEntity =sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.TWO);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
if (userDTO != null) {
logger.error("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.TWO).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
assignee = null;

View File

@ -1,17 +1,21 @@
package io.renren.modules.processForm.listener.v3;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import io.renren.common.annotation.ActivitiNoticeOperation;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.listener.v3.ApplyDistrictListener;
import io.renren.modules.sys.dao.SysUserDao;
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.entity.SysRegionEntity;
import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.enums.RegionLevelEnum;
import io.renren.modules.sys.service.SysDeptService;
import io.renren.modules.sys.service.SysRegionService;
import io.renren.modules.sys.service.SysRoleService;
import io.renren.modules.sys.service.SysUserService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.*;
import org.activiti.engine.delegate.event.ActivitiEvent;
@ -22,8 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.Map;
import java.util.*;
/**
* 资源所属区市管理员审批
@ -36,10 +39,14 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
@Autowired
private TaskService taskService;
@Autowired
private SysUserService sysUserService;
private SysUserDao sysUserDao;
@Autowired
private SysRoleService sysRoleService;
@Value("${big_date.assignee_role_name}")
@Autowired
private SysRegionService sysRegionService;
@Autowired
private SysDeptService sysDeptService;
@Value("${big_date.assignee_district_role_name}")
private String roleName; // 具备审批的角色名称
@Override
@ -60,7 +67,6 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
}
private void create(DelegateTask delegateTask) {
// TODO 暂时使用部门代替资源所属区
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
@ -71,15 +77,20 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
SysDeptDTO deptDTO = abilityApplicationDTO.getResourceOwnerDept();
logger.error("deptDTOId:" + deptDTO.getId());
SysRegionEntity regionEntity =sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptDTO.getId(), roleDTO.getId());
if (userDTO != null) {
logger.error("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
List<SysUserEntity> userList = sysUserDao.getList(ImmutableMap.of("role_id", roleDTO.getId()));
Optional<SysUserEntity> userEntityOptional = userList.stream()
.filter(user -> Objects.equals(regionEntity.getId(), sysRegionService.getByLevel(sysDeptService.get(user.getDeptId()).getDistrict(), RegionLevelEnum.THREE).getId())).findFirst();
if (userEntityOptional.isPresent()) {
logger.error("审批人id:" + userEntityOptional.get().getId());
taskService.setAssignee(delegateTask.getId(), userEntityOptional.get().getId().toString());
assignee = userEntityOptional.get().getId().toString();
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
assignee = null;

View File

@ -4,6 +4,7 @@ import io.renren.common.service.BaseService;
import io.renren.modules.sys.dto.SysRegionDTO;
import io.renren.modules.sys.dto.region.RegionProvince;
import io.renren.modules.sys.entity.SysRegionEntity;
import io.renren.modules.sys.enums.RegionLevelEnum;
import java.util.List;
import java.util.Map;
@ -29,4 +30,9 @@ public interface SysRegionService extends BaseService<SysRegionEntity> {
int getCountByPid(Long pid);
List<RegionProvince> getRegion(boolean threeLevel);
/**
* 根据level获取当前或父级region
*/
SysRegionEntity getByLevel(Long regionId, RegionLevelEnum levelEnum);
}

View File

@ -164,4 +164,12 @@ public class SysRegionServiceImpl extends BaseServiceImpl<SysRegionDao, SysRegio
return provinces;
}
public SysRegionEntity getByLevel(Long regionId, RegionLevelEnum levelEnum) {
SysRegionEntity entity = baseDao.getById(regionId);
if (entity.getTreeLevel() > levelEnum.value()) {
entity = getByLevel(entity.getPid(), levelEnum);
}
return entity;
}
}

View File

@ -70,6 +70,8 @@ resource:
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
assignee_district_role_name: 区审批人
assignee_city_role_name: 市审批人
# 平台部署级别 (PROVINCE:省 PREFECTURE:地级市 DISTRICT:区县 STREET:街道)
stage: PREFECTURE