区、市监听器:修改表单字段获取逻辑

This commit is contained in:
lizhicheng 2022-08-24 18:10:21 +08:00 committed by Koi-tsk
parent 738208ba2e
commit e1d1d964ab
3 changed files with 97 additions and 87 deletions

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
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;
@ -75,34 +71,41 @@ public class ApplyDistrictListener implements TaskListener, ExecutionListener, A
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
if(kv.containsKey("userId")){
Long applyUserId = Long.valueOf(kv.get("userId").toString());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(applyUserId).getDeptId());
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
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());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
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()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
}else{
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
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;
@ -75,34 +71,42 @@ public class CityListener implements TaskListener, ExecutionListener, ActivitiEv
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
if (kv.containsKey("userId")) {
Long applyUserId = Long.valueOf(kv.get("userId").toString());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(applyUserId).getDeptId());
SysDeptDTO deptDTO = sysDeptService.get(sysUserService.get(Long.parseLong(abilityApplicationDTO.getUserId())).getDeptId());
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.TWO);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.TWO);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
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();
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()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override

View File

@ -1,12 +1,8 @@
package io.renren.modules.processForm.listener.v3;
import com.alibaba.fastjson.JSON;
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;
@ -72,34 +68,41 @@ public class OwnerDistrictListener implements TaskListener, ExecutionListener, A
private void create(DelegateTask delegateTask) {
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
GsonBuilder builder = new GsonBuilder();
builder.registerTypeAdapter(Date.class, (JsonDeserializer<Date>) (json, typeOfT, context) -> new Date(json.getAsJsonPrimitive().getAsLong()));
Gson gson = builder.create();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
if (kv.containsKey("deptId")) { // 存在部门id
Long deptId = Long.valueOf(kv.get("deptId").toString());
SysDeptDTO deptDTO = sysDeptService.get(deptId);
SysDeptDTO deptDTO = abilityApplicationDTO.getResourceOwnerDept();
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
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();
String userId = null;
if (deptDTO.getDistrict() != null) {
SysRegionEntity regionEntity = sysRegionService.getByLevel(deptDTO.getDistrict(), RegionLevelEnum.THREE);
logger.error("regionEntityId:" + regionEntity.getId());
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
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()) {
userId = userEntityOptional.get().getId().toString();
}
}
if (userId != null) {
logger.error("审批人id:" + userId);
taskService.setAssignee(delegateTask.getId(), userId);
assignee = userId;
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
logger.error("分配的用户id为:{}", assignee);
} else {
logger.error("未查到 {} 对应 " + roleName, deptDTO.getName());
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
try {
logger.error("流程参数异常" + JSON.toJSONString(kv));
} catch (Exception exception) {
logger.error("流程参数异常", exception);
}
}
logger.error("分配的用户id为:{}", assignee);
}
@Override