|
@@ -23,6 +23,7 @@ import org.springblade.core.log.exception.ServiceException;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.mp.support.Condition;
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
import org.springblade.core.redis.cache.BladeRedis;
|
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.api.R;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
@@ -325,6 +326,16 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
//已审批人员List
|
|
//已审批人员List
|
|
Set<String> auditUserIdCompleteList = new HashSet<>(Func.toStrList(taskProcessInfo.getAuditUserIdsComplete()));
|
|
Set<String> auditUserIdCompleteList = new HashSet<>(Func.toStrList(taskProcessInfo.getAuditUserIdsComplete()));
|
|
|
|
|
|
|
|
+ //待审批的首位审批人,如果首位审批人还未审批,那么后面人员无法审批
|
|
|
|
+ if (auditUserIdList.size() > 0) {
|
|
|
|
+ String firstUserId = auditUserIdList.get(0);
|
|
|
|
+ if (!firstUserId.equals(SecureUtil.getUserId() + "")) {
|
|
|
|
+ User user = iUserClient.userInfoById(Long.parseLong(firstUserId)).getData();
|
|
|
|
+ bladeRedis.del("user:id=" + SecureUtil.getUserId());//解锁
|
|
|
|
+ throw new ServiceException("当前任务的审批人【" + user.getRealName() + "】还未完成审批流程,请稍后再试");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
//剔除待审批中当前用户信息
|
|
//剔除待审批中当前用户信息
|
|
if (auditUserIdList.removeIf(next -> next != null && next.equals(SecureUtil.getUserId() + ""))) {
|
|
if (auditUserIdList.removeIf(next -> next != null && next.equals(SecureUtil.getUserId() + ""))) {
|
|
//剔除后视为已完成审批
|
|
//剔除后视为已完成审批
|
|
@@ -708,23 +719,6 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 根据部门id获取部门负责人信息
|
|
|
|
- *
|
|
|
|
- * @param deptId
|
|
|
|
- * @return
|
|
|
|
- */
|
|
|
|
- public User getDepartmentHead(Long deptId) {
|
|
|
|
- if (ObjectUtil.isNotEmpty(deptId)) {
|
|
|
|
- //TODO 根据部门id获取部门负责人信息
|
|
|
|
- User user = new User();
|
|
|
|
- user.setId(SnowFlakeUtil.getId());
|
|
|
|
- user.setDeptId("123456789");
|
|
|
|
- return user;
|
|
|
|
- }
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 获取计划任务List
|
|
* 获取计划任务List
|
|
*
|
|
*
|
|
@@ -748,5 +742,185 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 构造审批任务
|
|
|
|
+ *
|
|
|
|
+ * @param type 任务类型
|
|
|
|
+ * @param taskProcessInfo 任务实体
|
|
|
|
+ */
|
|
|
|
+ public void buildTaskProcessInfoImpl(int type, TaskProcessInfo taskProcessInfo) {
|
|
|
|
+ taskProcessInfo.setId(SnowFlakeUtil.getId());
|
|
|
|
+ taskProcessInfo.setStatus(1); //待审批
|
|
|
|
+ taskProcessInfo.setReportDate(new Date());
|
|
|
|
+ taskProcessInfo.setTaskType(type);
|
|
|
|
+ String taskNameByType = this.taskNameByType(type);
|
|
|
|
+ if (StringUtils.isNotEmpty(taskNameByType)) {
|
|
|
|
+ taskProcessInfo.setTaskName("【" + SecureUtil.getUserName() + "】" + taskNameByType);
|
|
|
|
+ }
|
|
|
|
+ //上报人
|
|
|
|
+ taskProcessInfo.setReportUserId(SecureUtil.getUserId());
|
|
|
|
+
|
|
|
|
+ //构造审批人auditUserIds
|
|
|
|
+ List<String> auditUserIds = new LinkedList<>();
|
|
|
|
+
|
|
|
|
+ //判断当前用户是否是部门负责人,如果是,那么不自己审批(跳过)
|
|
|
|
+ User user = iUserClient.userInfoById(SecureUtil.getUserId()).getData();
|
|
|
|
+ if (user != null && ObjectUtil.isEmpty(user.getIsLeader())) {
|
|
|
|
+ //负责人getIsLeader字段=null,证明不是负责人,那么获取当前部门负责人
|
|
|
|
+ User departmentHead = this.getDepartmentHead(Long.parseLong(SecureUtil.getUser().getDeptId()));
|
|
|
|
+ auditUserIds.add(departmentHead.getId() + "");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //获取审批人信息
|
|
|
|
+ Map<String, List<User>> approveUserMaps = this.getApproveUserMaps(type);
|
|
|
|
+
|
|
|
|
+ //审批人
|
|
|
|
+ List<User> spUserList = approveUserMaps.get("SP");
|
|
|
|
+ if (spUserList.size() == 0) {
|
|
|
|
+ throw new ServiceException("获取当前审批流程人员信息失败,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ auditUserIds.addAll(spUserList.stream().map(User::getId).map(String::valueOf).collect(Collectors.toList()));
|
|
|
|
+
|
|
|
|
+ List<String> nonEmptyAuditUserIds = new LinkedList<>();
|
|
|
|
+ for (String userId : auditUserIds) {
|
|
|
|
+ if (StringUtils.isNotEmpty(userId)) {
|
|
|
|
+ nonEmptyAuditUserIds.add(userId);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (nonEmptyAuditUserIds.size() == 0) {
|
|
|
|
+ taskProcessInfo.setAuditUserIds(null);
|
|
|
|
+ } else {
|
|
|
|
+ taskProcessInfo.setAuditUserIds(StringUtils.join(nonEmptyAuditUserIds, ","));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //抄送人
|
|
|
|
+ List<User> zcUserList = approveUserMaps.get("ZC");
|
|
|
|
+ if (zcUserList.size() > 0) {
|
|
|
|
+ List<String> zcUserIds = zcUserList.stream().map(User::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
|
+ taskProcessInfo.setCcUserIds(StringUtils.join(zcUserIds, ","));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //入库
|
|
|
|
+ this.save(taskProcessInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据任务类型获取任务名称
|
|
|
|
+ *
|
|
|
|
+ * @param type
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ private String taskNameByType(int type) {
|
|
|
|
+ switch (type) {
|
|
|
|
+ case 2:
|
|
|
|
+ return "向您发起【报销审批】审批";
|
|
|
|
+ case 3:
|
|
|
|
+ return "向您发起【支付审批】审批";
|
|
|
|
+ case 4:
|
|
|
|
+ return "向您发起【借款审批】审批";
|
|
|
|
+ case 5:
|
|
|
|
+ return "向您发起【采购审批】审批";
|
|
|
|
+ case 6:
|
|
|
|
+ return "向您发起【用车审批】审批";
|
|
|
|
+ case 7:
|
|
|
|
+ return "向您发起【发票审批】审批";
|
|
|
|
+ case 8:
|
|
|
|
+ return "向您发起【外包支付】审批";
|
|
|
|
+ case 9:
|
|
|
|
+ return "向您发起【出差审批】审批";
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据部门id获取部门负责人信息(一个部门只有一个负责人)
|
|
|
|
+ *
|
|
|
|
+ * @param deptId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public User getDepartmentHead(Long deptId) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(deptId)) {
|
|
|
|
+ List<User> leaderUser = jdbcTemplate.query("select * from blade_user where dept_id like '%" + deptId + "%' and is_leader like '%" + deptId + "%'", new BeanPropertyRowMapper<>(User.class));
|
|
|
|
+ if (leaderUser.size() == 1) {
|
|
|
|
+ return leaderUser.get(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据审批类型获取审批人id信息(不包括部门负责人,单独处理)
|
|
|
|
+ *
|
|
|
|
+ * @param type 数据类型
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Map<String, List<User>> getApproveUserMaps(int type) {
|
|
|
|
+ //tenant_id = 003077(管控平台) dept_type = 3(最底层为岗位信息)
|
|
|
|
+ List<Dept> deptListControl = jdbcTemplate.query("select * from blade_dept where tenant_id = 003077 and dept_type = 3", new BeanPropertyRowMapper<>(Dept.class));
|
|
|
|
+ Map<String, List<User>> resultMaps = new LinkedHashMap<>();
|
|
|
|
+ List<String> spPostIds = new LinkedList<>();
|
|
|
|
+ List<String> zcPostIds = new LinkedList<>();
|
|
|
|
+ List<DictInfo> query = new ArrayList<>();
|
|
|
|
+ switch (type) {
|
|
|
|
+ case 2://财务报销
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%财务报销%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 3://支付申请
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%支付申请%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 4://借款申请
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%借款申请%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 5://采购申请
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%采购申请%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 6://用车审批
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%用车申请%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 7://发票审批
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%发票管理%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 8://外包支付
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%外包支付%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ case 9://出差审批
|
|
|
|
+ query = jdbcTemplate.query("select id from c_dict_info where dict_name like '%出差管理%' and type = 6", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (query.size() == 1) {
|
|
|
|
+ DictInfo dictInfo = query.get(0);
|
|
|
|
+ List<TaskProcessRecordDictInfo> dictInfoList = jdbcTemplate.query("select * from c_task_process_record_dict_info where dict_id = " + dictInfo.getId(), new BeanPropertyRowMapper<>(TaskProcessRecordDictInfo.class));
|
|
|
|
+ if (dictInfoList.size() > 0) {
|
|
|
|
+ List<TaskProcessRecordDictInfo> spRoleInfos = dictInfoList.stream().filter(f -> f.getType().equals(1))
|
|
|
|
+ .sorted(Comparator.comparingInt(TaskProcessRecordDictInfo::getSort))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ List<TaskProcessRecordDictInfo> zcRoleInfos = dictInfoList.stream().filter(f -> f.getType().equals(2))
|
|
|
|
+ .sorted(Comparator.comparingInt(TaskProcessRecordDictInfo::getSort))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ for (TaskProcessRecordDictInfo spRoleInfo : spRoleInfos) {
|
|
|
|
+ for (Dept dept : deptListControl) {
|
|
|
|
+ if (spRoleInfo.getRoleName().equals(dept.getDeptName())) {
|
|
|
|
+ spPostIds.add(dept.getId() + "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (TaskProcessRecordDictInfo zcRoleInfo : zcRoleInfos) {
|
|
|
|
+ for (Dept dept : deptListControl) {
|
|
|
|
+ if (zcRoleInfo.getRoleName().equals(dept.getDeptName())) {
|
|
|
|
+ zcPostIds.add(dept.getId() + "");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<User> spUserList = jdbcTemplate.query("select * from blade_user where tenant_id = 003077 and dept_id in(" + StringUtils.join(spPostIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
|
|
|
|
+ List<User> zcUserList = jdbcTemplate.query("select * from blade_user where tenant_id = 003077 and dept_id in(" + StringUtils.join(zcPostIds, ",") + ")", new BeanPropertyRowMapper<>(User.class));
|
|
|
|
+ resultMaps.put("SP", spUserList);
|
|
|
|
+ resultMaps.put("ZC", zcUserList);
|
|
|
|
+ return resultMaps;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|