配置文件新增默认审批人id

This commit is contained in:
dinggang 2022-08-03 16:26:04 +08:00
parent d0c8b4ae5f
commit d945bad3a5
10 changed files with 67 additions and 57 deletions

View File

@ -46,6 +46,8 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -143,8 +145,8 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
assignee = userDTO.getId().toString();
} else {
logger.error("未查到该部门对应的{} ", roleName);
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
assignee = "1516728698224427010";
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
} else { // 填入大数据审批人
logger.error("大数据局名称:{}", bigDateDeptName);
@ -157,9 +159,9 @@ public class DemandDataListener implements TaskListener, ExecutionListener, Acti
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
logger.error("未查到大数据部门对应 {}", roleName);
assignee = "1516728698224427010";
assignee = defaultAssigneeRoleId;
}
}

View File

@ -38,6 +38,8 @@ public class CommentListener implements TaskListener, ExecutionListener, Activit
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -137,9 +139,9 @@ public class CommentListener implements TaskListener, ExecutionListener, Activit
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
delegateTask.setAssignee("1516728698224427010");
delegateTask.setAssignee(defaultAssigneeRoleId);
logger.error("未查到该部门对应 {}", roleName);
assignee = "1516728698224427010";
assignee = defaultAssigneeRoleId;
}
Map<String, Object> kv = delegateTask.getVariables();

View File

@ -126,7 +126,7 @@ public class TAbilityApplicationController {
tAbilityApplicationService.getByInstanceId(inStanceId + "");
if (!dtos.isEmpty()) {
dtos.stream()
.limit(1l)
.limit(1L)
.forEach(dto -> {
BeanUtils.copyProperties(dto, index);
if (StringUtils.isNotEmpty(index.getCameraList())) {
@ -140,11 +140,11 @@ public class TAbilityApplicationController {
});
}
if (params.containsKey("ended")) {
index.setEnded(Boolean.valueOf(params.get("ended").toString()));
index.setEnded(Boolean.parseBoolean(params.get("ended").toString()));
} else {
String sql = String.format("SELECT IF(COUNT(id) >0 ,FALSE,TRUE) AS ended FROM t_ability_application WHERE apply_flag = '%s' AND EXISTS (SELECT 1 FROM t_ability_application t1 WHERE t1.apply_flag = t_ability_application.apply_flag AND approve_status = '审核中');", index.getApplyFlag());
Boolean ended = jdbcTemplate.queryForObject(sql, Boolean.class);
index.setEnded(ended);
index.setEnded(Boolean.TRUE.equals(ended));
}
return index;
}).collect(Collectors.toList());
@ -160,7 +160,7 @@ public class TAbilityApplicationController {
@GetMapping("deal")
public Result<String> test() {
List<Map<String, Object>> re = jdbcTemplate.queryForList("SELECT t_ability_application.id,t_ability_application.resource_id,tb_data_resource.dept_id from t_ability_application JOIN tb_data_resource ON t_ability_application.resource_id = tb_data_resource.id WHERE resource_owner_dept IS NULL;");
re.stream().forEach(index -> {
re.forEach(index -> {
SysDeptDTO sysDeptDTO = sysDeptService.get(Long.valueOf(index.get("dept_id").toString()));
if (sysDeptDTO != null) {
jdbcTemplate.update(String.format("UPDATE t_ability_application SET resource_owner_dept = '%s' WHERE id = %s", JSON.toJSONString(sysDeptDTO), index.get("id").toString()));

View File

@ -43,10 +43,12 @@ import java.util.UUID;
*/
@Component
public class CorrectionListener implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
private static Logger logger = LoggerFactory.getLogger(CorrectionListener.class);
private static final Logger logger = LoggerFactory.getLogger(CorrectionListener.class);
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -93,17 +95,15 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
logger.error("----------------------进入部门审批结束节点---------------------------");
delegateExecution.getProcessBusinessKey();
final String eventName = delegateExecution.getEventName();
switch (eventName) {
case EVENTNAME_END:
endTake(delegateExecution.getVariables());
break;
if (EVENTNAME_END.equals(eventName)) {
endTake(delegateExecution.getVariables());
}
}
@Override
public void onEvent(ActivitiEvent activitiEvent) { // 事件回调
logger.error("事件类型:" + activitiEvent.getType().toString());
logger.error("" + activitiEvent.getProcessDefinitionId());
logger.error("事件类型:{}", activitiEvent.getType().toString());
logger.error( activitiEvent.getProcessDefinitionId());
}
@Override
@ -113,7 +113,7 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
logger.error("异常", delegateExecution);
logger.error("异常{}", delegateExecution);
}
@ -134,12 +134,12 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
abilityApplicationDTO.setDelFlag(0);
abilityApplicationDTO.setApproveStatus("不通过");
tAbilityApplicationService.update(abilityApplicationDTO);
logger.error("审批不通过申请id:" + abilityApplicationDTO.getId());
logger.error("审批不通过申请id:{}", abilityApplicationDTO.getId());
} else {
abilityApplicationDTO.setDelFlag(0);
abilityApplicationDTO.setApproveStatus("通过");
tAbilityApplicationService.update(abilityApplicationDTO);
logger.error("审批通过申请id:" + abilityApplicationDTO.getId());
logger.error("审批通过申请id:{}", abilityApplicationDTO.getId());
jdbcTemplate.update("update tb_data_resource,\n" +
"tb_data_resource_assignmark\n" +
"SET tb_data_resource.total = round(tb_data_resource_assignmark.total) WHERE tb_data_resource.id =" + abilityApplicationDTO.getResourceId());
@ -164,11 +164,11 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
logger.error("roleDTOId:{}", roleDTO.getId());
ResourceDTO resourceEntityDto = null;
Long deptId = null;
if (abilityApplicationDTO != null) {
logger.error("abilityApplicationDTO:" + abilityApplicationDTO.toString());
logger.error("abilityApplicationDTO:{}", abilityApplicationDTO.toString());
resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()));
}
if (resourceEntityDto != null && resourceEntityDto.getDeptId() != null) {
@ -176,7 +176,7 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
SysDeptDTO deptDTO =
sysDeptService.get(resourceEntityDto.getDeptId());
if (deptDTO != null && deptDTO.getName().equals(bigDateDeptName)) {
logger.error("第二级别审批仍然为 " + bigDateDeptName);
logger.error("第二级别审批仍然为 {}", bigDateDeptName);
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
if (userDTO != null) {
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
@ -187,10 +187,10 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
return;
}
} else {
logger.error("表单内单位名称:" + abilityApplicationDTO.getUnit());
logger.error("表单内单位名称:{}", abilityApplicationDTO.getUnit());
SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit());
if (deptDTO != null) {
logger.error("deptDTOId:" + deptDTO.getId());
logger.error("deptDTOId:{}", deptDTO.getId());
deptId = deptDTO.getId();
}
@ -205,8 +205,8 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
assignee = userDTO.getId().toString();
} else {
logger.error("未查到该部门对应的 " + roleName);
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
assignee = "1516728698224427010";
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
mpComplete(abilityApplicationDTO, delegateTask, assignee);
}

View File

@ -40,6 +40,8 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -112,9 +114,9 @@ public class DataCenterListener implements TaskListener, ExecutionListener, Acti
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
delegateTask.setAssignee("1516728698224427010");
delegateTask.setAssignee(defaultAssigneeRoleId);
logger.error("未查到该部门对应 " + roleName);
assignee = "1516728698224427010";
assignee = defaultAssigneeRoleId;
}
Map<String, Object> kv = delegateTask.getVariables();

View File

@ -43,10 +43,12 @@ import java.util.stream.Collectors;
*/
@Component
public class CorrectionListenerV2 implements TaskListener, ExecutionListener, ActivitiEventListener, JavaDelegate {
private static Logger logger = LoggerFactory.getLogger(CorrectionListenerV2.class);
private static final Logger logger = LoggerFactory.getLogger(CorrectionListenerV2.class);
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -93,17 +95,15 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
logger.error("----------------------进入部门审批结束节点---------------------------");
delegateExecution.getProcessBusinessKey();
final String eventName = delegateExecution.getEventName();
switch (eventName) {
case EVENTNAME_END:
endTake(delegateExecution);
break;
if (EVENTNAME_END.equals(eventName)) {
endTake(delegateExecution);
}
}
@Override
public void onEvent(ActivitiEvent activitiEvent) { // 事件回调
logger.error("事件类型:" + activitiEvent.getType().toString());
logger.error("" + activitiEvent.getProcessDefinitionId());
logger.error("事件类型:{}", activitiEvent.getType().toString());
logger.error(activitiEvent.getProcessDefinitionId());
}
@Override
@ -113,7 +113,7 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
@Override
public void execute(DelegateExecution delegateExecution) throws Exception {
logger.error("异常", delegateExecution);
logger.error("异常{}", delegateExecution);
}
@ -165,13 +165,13 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
String assignee;
Map<String, Object> kv = delegateTask.getVariables();
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.error("roleDTOId:" + roleDTO.getId());
logger.error("roleDTOId:{}", roleDTO.getId());
Long deptId;
if (kv.containsKey("deptId")) { // 存在部门id
deptId = Long.valueOf(kv.get("deptId").toString());
SysDeptDTO deptDTO = sysDeptService.get(deptId);
if (deptDTO != null && deptDTO.getName().equals(bigDateDeptName)) { // 二级审批依然为大数据局,默认审核通过
logger.error("第二级别审批仍然为 " + bigDateDeptName);
logger.error("第二级别审批仍然为 {}", bigDateDeptName);
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
if (userDTO != null) {
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
@ -186,13 +186,13 @@ public class CorrectionListenerV2 implements TaskListener, ExecutionListener, Ac
userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
}
if (userDTO != null) {
logger.error("审批人id:" + userDTO.getId());
logger.error("审批人id:{}", userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
logger.error("未查到该部门 {} 对应的 " + roleName, deptId);
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
assignee = "1516728698224427010";
logger.error("未查到该部门 {} 对应的 {}", deptId, roleName);
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
if (kv.containsKey("tAbilityApplicationDTOList")) {
List<TAbilityApplicationDTO> dtoList = (List<TAbilityApplicationDTO>) kv.get("tAbilityApplicationDTOList");

View File

@ -41,6 +41,8 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -174,8 +176,8 @@ public class ResourceUndercarriageListener implements TaskListener, ExecutionLis
assignee = userDTO.getId().toString();
} else {
logger.error("未查到大数据部门对应 " + roleName);
taskService.setAssignee(taskId, "1516728698224427010");
assignee = "1516728698224427010";
taskService.setAssignee(taskId, defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
return assignee;
}

View File

@ -41,6 +41,8 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
@Value("${big_date.name}")
private String bigDateDeptName; // 大数据局名称
@Value("${big_date.default_assignee_role_id}")
private String defaultAssigneeRoleId; // 当某部门未设置部门审批人时将使用该用户审批
@Value("${big_date.assignee_role_name}")
private String roleName; // 具备审批的角色名称
@ -208,8 +210,8 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
assignee = userDTO.getId().toString();
} else {
logger.error("未查到该部门对应的 " + roleName);
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
assignee = "1516728698224427010";
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
assignee = defaultAssigneeRoleId;
}
} else if (resourceMountApplyDTO.getDeptId() != null) {
SysUserDTO userDTO = sysUserService.getByDeptIdAndRoleId(Long.valueOf(resourceMountApplyDTO.getDeptId()), roleDTO.getId());
@ -218,9 +220,9 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
logger.error("未查到部门对应 " + resourceMountApplyDTO.getDeptId());
assignee = "1516728698224427010";
assignee = defaultAssigneeRoleId;
}
} else {
logger.error("大数据局名称:" + bigDateDeptName);
@ -233,9 +235,9 @@ public class ResourceOwnerListener implements TaskListener, ExecutionListener, A
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
assignee = userDTO.getId().toString();
} else {
taskService.setAssignee(delegateTask.getId(), "1516728698224427010");
taskService.setAssignee(delegateTask.getId(), defaultAssigneeRoleId);
logger.error("未查到大数据部门对应 " + roleName);
assignee = "1516728698224427010";
assignee = defaultAssigneeRoleId;
}
}

View File

@ -229,7 +229,6 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
String OU = ou + "," + "OU=" + mName;
LdapContext ldapContext = jhlDAPTool.LDAP_connect(OU);
List<Map<String, Object>> lists = jhlDAPTool.readLdap(ldapContext, "(&(OU=*)(ou=*)(!(sAMAccountType=*))(instanceType=4))");
//Iterator<Map<String,Object>> iterator = lists.iterator();
//给pid pids赋值
if (lists.size() > 0) {
lists.forEach(dept -> {//1.遍历每一个map
@ -241,10 +240,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
String dName = namespaces[i].split("=")[1];//具体的上级部门名称
int c = i;
for (int j = 0; j < lists.size(); j++) {
Map<String, Object> map = new HashMap<>();
if (dName.equals(lists.get(j).get("name").toString())) {
String id = lists.get(j).get("id").toString();
String pidsOld = dept.get("pids").toString() == "" ? "" : (dept.get("pids").toString() + ",");
String pidsOld = Objects.equals(dept.get("pids").toString(), "") ? "" : (dept.get("pids").toString() + ",");
if (c == 1) {
dept.put("pid", id);
dept.put("pids", pidsOld + id);
@ -257,7 +255,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
}
});
//给district和type赋值
String districtName, type;
String districtName;
Long distict;
switch (key) {
case "新市北区":
@ -377,7 +375,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
for (int i = 1; i <= size; i++) {
LdapContext ldapContext = jhlDAPTool.LDAP_connect(deptList.get(i - 1).get(String.valueOf(i)).toString());
List<Map> maps = jhlDAPTool.readLdap(ldapContext);
if (maps.size() > 0) {
if (!maps.isEmpty()) {
maps.forEach(m -> {
//根据username判断
if (m.get(("username")) != null) {
@ -402,7 +400,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit
String dept, deptFather;
dept = deptArray[1];
deptFather = deptArray[2];
long id = getDeptId(dept.substring(3, dept.length()), deptFather.substring(3, deptFather.length()));
long id = getDeptId(dept.substring(3), deptFather.substring(3));
newUser.setDeptId(id);
sysUserDao.insert(newUser);
}

View File

@ -7,6 +7,8 @@ project:
big_date:
name: 青岛市大数据发展管理局
assignee_role_name: 部门审批人
# 当某部门未设置部门审批人时,将使用该用户审批
default_assignee_role_id: 1516728698224427010
# 需要进行统计数目的资源 type/需要进行统计申请的资源类型 applyType
census:
type: 组件服务,应用资源,基础设施,数据资源,知识库