|
@@ -73,24 +73,29 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
throw new ServiceException("未获取到当前用户信息,请联系管理员");
|
|
|
}
|
|
|
QueryWrapper<TaskProcessInfo> queryWrapper = Condition.getQueryWrapper(dto);
|
|
|
+ boolean var = true;
|
|
|
switch (dto.getSelectType()) {
|
|
|
case "1": //待审批为待办任务
|
|
|
queryWrapper.lambda().like(TaskProcessInfo::getAuditUserIds, SecureUtil.getUserId());
|
|
|
queryWrapper.lambda().eq(TaskProcessInfo::getStatus, 1);
|
|
|
break;
|
|
|
case "2": //已审核、已驳回为已办任务
|
|
|
- queryWrapper.lambda().apply("(audit_user_ids_complete LIKE '%" + SecureUtil.getUserId() + "%' AND STATUS IN ( 2, 3 )) OR (audit_user_ids LIKE '%" + SecureUtil.getUserId() + "%' AND STATUS = 3)");
|
|
|
+ if (dto.getSelectStatus().equals("0") || dto.getSelectStatus().equals("1")) {
|
|
|
+ var = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getSelectStatus())) {
|
|
|
+ queryWrapper.lambda().apply("(audit_user_ids_complete LIKE '%" + SecureUtil.getUserId() + "%' OR audit_user_ids LIKE '%" + SecureUtil.getUserId() + "%') AND STATUS =" + dto.getSelectStatus());
|
|
|
+ } else {
|
|
|
+ queryWrapper.lambda().apply("(audit_user_ids_complete LIKE '%" + SecureUtil.getUserId() + "%' OR audit_user_ids LIKE '%" + SecureUtil.getUserId() + "%') AND STATUS IN(2,3)");
|
|
|
+ }
|
|
|
break;
|
|
|
case "3": //我发起的任务
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getSelectStatus()) && !dto.getSelectStatus().equals("1")) {
|
|
|
- queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
- }
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
queryWrapper.lambda().eq(TaskProcessInfo::getReportUserId, SecureUtil.getUserId());
|
|
|
break;
|
|
|
case "4": //抄送给我的
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getSelectStatus()) && !dto.getSelectStatus().equals("1")) {
|
|
|
- queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
- }
|
|
|
+ queryWrapper.lambda().eq(TaskProcessInfo::getStatus, dto.getSelectStatus());
|
|
|
queryWrapper.lambda().like(TaskProcessInfo::getCcUserIds, SecureUtil.getUserId());
|
|
|
break;
|
|
|
}
|
|
@@ -99,55 +104,59 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
queryWrapper.lambda().between(TaskProcessInfo::getReportDate, dto.getStartTime(), endTime);
|
|
|
}
|
|
|
- IPage<TaskProcessInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TaskProcessInfo::getReportDate));
|
|
|
|
|
|
- List<DictInfo> dictInfoList = jdbcTemplate.query("select dict_name,dict_value from c_dict_info where code = 'report_type'", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
+ if (var) {
|
|
|
+ IPage<TaskProcessInfo> pages = this.page(page, queryWrapper.lambda().orderBy(true, false, TaskProcessInfo::getReportDate));
|
|
|
|
|
|
- Map<Long, String> userMap = iUserClient.selectUserAll().stream().filter(f -> ObjectUtil.isNotEmpty(f.getRealName())).collect(Collectors.toMap(User::getId, User::getRealName));
|
|
|
+ List<DictInfo> dictInfoList = jdbcTemplate.query("select dict_name,dict_value from c_dict_info where code = 'report_type'", new BeanPropertyRowMapper<>(DictInfo.class));
|
|
|
|
|
|
- return pages.convert((obj -> {
|
|
|
- TaskProcessInfoVO vo = new TaskProcessInfoVO();
|
|
|
- BeanUtils.copyProperties(obj, vo);
|
|
|
+ Map<Long, String> userMap = iUserClient.selectUserAll().stream().filter(f -> ObjectUtil.isNotEmpty(f.getRealName())).collect(Collectors.toMap(User::getId, User::getRealName));
|
|
|
|
|
|
- if (dto.getSelectType().equals("3") && vo.getReportUserId().equals(SecureUtil.getUserId())) {
|
|
|
- //如果是本身,也就是我发起的任务,那么替换任务名称
|
|
|
- String taskName = vo.getTaskName();
|
|
|
- String re = taskName.replace("向您发起", "我发起的");
|
|
|
- vo.setTaskName(re);
|
|
|
- }
|
|
|
- if (dto.getSelectType().equals("4")) {
|
|
|
- //抄送给我的
|
|
|
- String taskName = vo.getTaskName();
|
|
|
- String re = taskName.replace("向您发起", "抄送给您的");
|
|
|
- vo.setTaskName(re);
|
|
|
- }
|
|
|
+ return pages.convert((obj -> {
|
|
|
+ TaskProcessInfoVO vo = new TaskProcessInfoVO();
|
|
|
+ BeanUtils.copyProperties(obj, vo);
|
|
|
|
|
|
- vo.setReportUserName(userMap.get(vo.getReportUserId()));
|
|
|
+ if (dto.getSelectType().equals("3") && vo.getReportUserId().equals(SecureUtil.getUserId())) {
|
|
|
+ //如果是本身,也就是我发起的任务,那么替换任务名称
|
|
|
+ String taskName = vo.getTaskName();
|
|
|
+ String re = taskName.replace("向您发起", "我发起的");
|
|
|
+ vo.setTaskName(re);
|
|
|
+ }
|
|
|
+ if (dto.getSelectType().equals("4")) {
|
|
|
+ //抄送给我的
|
|
|
+ String taskName = vo.getTaskName();
|
|
|
+ String re = taskName.replace("向您发起", "抄送给您的");
|
|
|
+ vo.setTaskName(re);
|
|
|
+ }
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(vo.getAuditUserIds())) {
|
|
|
- List<String> auditUserNames = Arrays.stream(vo.getAuditUserIds().split(","))
|
|
|
- .map(Long::parseLong).map(userMap::get)
|
|
|
- .collect(Collectors.toList());
|
|
|
- vo.setAuditUserNames(StringUtils.join(auditUserNames, "、"));
|
|
|
- }
|
|
|
+ vo.setReportUserName(userMap.get(vo.getReportUserId()));
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(vo.getAuditUserIdsComplete())) {
|
|
|
- List<String> auditUserCompleteNames = Arrays.stream(vo.getAuditUserIdsComplete().split(","))
|
|
|
- .map(Long::parseLong).map(userMap::get)
|
|
|
- .collect(Collectors.toList());
|
|
|
- vo.setAuditUserCompleteNames(StringUtils.join(auditUserCompleteNames, "、"));
|
|
|
- }
|
|
|
+ if (StringUtils.isNotEmpty(vo.getAuditUserIds())) {
|
|
|
+ List<String> auditUserNames = Arrays.stream(vo.getAuditUserIds().split(","))
|
|
|
+ .map(Long::parseLong).map(userMap::get)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setAuditUserNames(StringUtils.join(auditUserNames, "、"));
|
|
|
+ }
|
|
|
|
|
|
- vo.setStatusName(vo.getStatus().equals(1) ? "待审批" : (vo.getStatus().equals(2) ? "已审批" : (vo.getStatus().equals(3) ? "已驳回" : "未上报")));
|
|
|
+ if (StringUtils.isNotEmpty(vo.getAuditUserIdsComplete())) {
|
|
|
+ List<String> auditUserCompleteNames = Arrays.stream(vo.getAuditUserIdsComplete().split(","))
|
|
|
+ .map(Long::parseLong).map(userMap::get)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ vo.setAuditUserCompleteNames(StringUtils.join(auditUserCompleteNames, "、"));
|
|
|
+ }
|
|
|
|
|
|
- for (DictInfo dictInfo : dictInfoList) {
|
|
|
- if ((vo.getTaskType()).equals(dictInfo.getDictValue().intValue())) {
|
|
|
- vo.setReportTypeName(dictInfo.getDictName());
|
|
|
- break;
|
|
|
+ vo.setStatusName(vo.getStatus().equals(1) ? "待审批" : (vo.getStatus().equals(2) ? "已审批" : (vo.getStatus().equals(3) ? "已驳回" : "未上报")));
|
|
|
+
|
|
|
+ for (DictInfo dictInfo : dictInfoList) {
|
|
|
+ if ((vo.getTaskType()).equals(dictInfo.getDictValue().intValue())) {
|
|
|
+ vo.setReportTypeName(dictInfo.getDictName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- return vo;
|
|
|
- }));
|
|
|
+ return vo;
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -527,7 +536,7 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
this.updateTaskStatus(businessDataType, 2, taskProcessInfo.getId(), record.getExpenseInfoId());
|
|
|
|
|
|
//处理审批闭环后的业务数据
|
|
|
- this.processTheServiceDataAfterTheApprovalClosedLoop(businessDataType, record.getExpenseInfoId());
|
|
|
+ this.processTheServiceDataAfterTheApprovalClosedLoop(businessDataType, taskProcessInfo.getId(), record.getExpenseInfoId());
|
|
|
|
|
|
//解锁
|
|
|
bladeRedis.del("user:id=" + SecureUtil.getUserId());
|
|
@@ -719,9 +728,6 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
}
|
|
|
if (ObjectUtil.isNotEmpty(dto.getTaskIds()) && ObjectUtil.isNotEmpty(dto.getUpdateType()) && ObjectUtil.isNotEmpty(dto.getCompletionTime())) {
|
|
|
List<String> taskIds = Func.toStrList(dto.getTaskIds());
|
|
|
- SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
- String completionTimeStr = dateFormatter.format(dto.getCompletionTime());
|
|
|
-
|
|
|
//获取所有审批任务与计划任务关系,判断计划任务状态
|
|
|
List<ExpenseTaskRecord> expenseTaskRecords = jdbcTemplate.query("select task_id,expense_info_id,is_transfer from c_expense_task_record where expense_info_type = 1 and expense_info_id in(" + dto.getTaskIds() + ")", new BeanPropertyRowMapper<>(ExpenseTaskRecord.class));
|
|
|
Map<String, ExpenseTaskRecord> taskRecordMaps = expenseTaskRecords.stream().collect(Collectors.toMap(ExpenseTaskRecord::getExpenseInfoId, Function.identity()));
|
|
@@ -742,6 +748,10 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
throw new ServiceException("当前选择的计划任务【" + (StringUtils.join(planTaskNames, "、")) + "】不是未提交或已驳回状态,操作失败");
|
|
|
}
|
|
|
|
|
|
+ //完成时间或转移时间
|
|
|
+ SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ String completionTimeStr = dateFormatter.format(dto.getCompletionTime());
|
|
|
+
|
|
|
//处理业务
|
|
|
for (String taskId : taskIds) {
|
|
|
ProjectCostBudget planTaskInfo = projectCostBudgetService.getById(taskId);
|
|
@@ -787,6 +797,17 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
//新增审批任务关联信息
|
|
|
jdbcTemplate.execute("delete from c_expense_task_record where expense_info_type = 1 and expense_info_id = " + planTaskInfo.getId() + " ; insert into c_expense_task_record(id,task_id,expense_info_id,expense_info_type) values (" + SnowFlakeUtil.getId() + "," + taskProcessInfo.getId() + "," + planTaskInfo.getId() + ",1)");
|
|
|
|
|
|
+ //新增计划任务是否逾期完成记录信息
|
|
|
+ if (ObjectUtil.isNotEmpty(planTaskInfo.getPlanEndTime())) {
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ Date planEndDate = Date.from(planTaskInfo.getPlanEndTime().atStartOfDay(ZoneId.systemDefault()).toInstant());
|
|
|
+ int comparison = now.compareTo(planEndDate);
|
|
|
+ if (comparison > 0) {
|
|
|
+ //now大于planEndDate表示逾期完成
|
|
|
+ jdbcTemplate.execute("delete from c_task_plan_overdue_status where plan_task_id = " + taskId + " ; insert into c_task_plan_overdue_status(id,user_id,plan_task_id,is_overdue) values (" + SnowFlakeUtil.getId() + "," + SecureUtil.getUserId() + "," + taskId + ",1)");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
} else if (dto.getUpdateType().equals("2")) {
|
|
|
//任务转移
|
|
|
TaskProcessInfo taskProcessInfo = new TaskProcessInfo();
|
|
@@ -897,7 +918,7 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
List<Dept> query = jdbcTemplate.query("select id from blade_dept where dept_name = '总经理' and tenant_id = " + SecureUtil.getUser().getTenantId() + " and dept_type = 3", new BeanPropertyRowMapper<>(Dept.class));
|
|
|
if (query.size() == 1) {
|
|
|
Dept dept = query.get(0);
|
|
|
- List<User> users = jdbcTemplate.query("select id from blade_user where dept_id like '%" + dept.getId() + "%' and tenant_id = " + SecureUtil.getUser().getTenantId() + " and is_deleted = 0", new BeanPropertyRowMapper<>(User.class));
|
|
|
+ List<User> users = jdbcTemplate.query("select id from blade_user where post_id like '%" + dept.getId() + "%' and role_id like '%" + dept.getId() + "%' and tenant_id = " + SecureUtil.getUser().getTenantId() + " and is_deleted = 0", new BeanPropertyRowMapper<>(User.class));
|
|
|
if (users.size() > 0) {
|
|
|
List<Long> ids = users.stream().map(User::getId).collect(Collectors.toList());
|
|
|
auditUserIds.add(StringUtils.join(ids, ","));
|
|
@@ -1021,18 +1042,21 @@ public class TaskProcessServiceImpl extends BaseServiceImpl<TaskProcessMapper, T
|
|
|
* 处理审批闭环后的业务数据
|
|
|
*
|
|
|
* @param businessDataType 业务类型
|
|
|
+ * @param approveTaskId 审批任务id
|
|
|
* @param dataId 业务id
|
|
|
*/
|
|
|
- private void processTheServiceDataAfterTheApprovalClosedLoop(Integer businessDataType, String dataId) {
|
|
|
+ private void processTheServiceDataAfterTheApprovalClosedLoop(Integer businessDataType, Long approveTaskId, String dataId) {
|
|
|
switch (businessDataType) {
|
|
|
case 1:
|
|
|
- //计划任务
|
|
|
+ //计划任务 task_approve = 1,status = 4 表示已完成,且通过审批
|
|
|
ProjectCostBudget projectCostBudget = jdbcTemplate.query("select * from c_project_cost_budget where id = " + dataId, new BeanPropertyRowMapper<>(ProjectCostBudget.class)).stream().findAny().orElse(null);
|
|
|
if (projectCostBudget != null && projectCostBudget.getStatus().equals(4) && projectCostBudget.getTaskApprove().equals(1)) {
|
|
|
- //已完成任务进行金额统计 budget_count_money(预算总金额) = actual_total_money(实际总金额)
|
|
|
- projectCostBudgetService.update(Wrappers.<ProjectCostBudget>lambdaUpdate().set(ProjectCostBudget::getActualTotalMoney, projectCostBudget.getBudgetCountMoney()).eq(ProjectCostBudget::getId, projectCostBudget.getId()));
|
|
|
- } else if (projectCostBudget != null && projectCostBudget.getStatus().equals(2) && projectCostBudget.getTaskApprove().equals(0)) {
|
|
|
- //驳回的任务,删除关联信息 TODO
|
|
|
+
|
|
|
+ //获取任务完成时间
|
|
|
+ TaskPlanUpdateStatusInfo taskPlanUpdateStatusInfo = jdbcTemplate.query("select completion_time from c_task_plan_update_status_info where update_type = 1 and approve_task_id = " + approveTaskId + " and plan_task_id = " + dataId, new BeanPropertyRowMapper<>(TaskPlanUpdateStatusInfo.class)).stream().findAny().orElse(null);
|
|
|
+ if (taskPlanUpdateStatusInfo != null) {
|
|
|
+ //修改任务实际完成时间、金额 TODO
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
break;
|