|
@@ -22,6 +22,7 @@ import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
|
+import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@@ -33,6 +34,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -85,6 +87,7 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
for (LogHistoryInfoReadVO readVO : infoReadVOS) {
|
|
|
readMap.put(readVO.getUserId() + readVO.getLogId() + "", readVO);
|
|
|
}
|
|
|
+ Map<Long, List<LogHistoryInfoReadVO>> logRecords = infoReadVOS.stream().collect(Collectors.groupingBy(LogHistoryInfoReadVO::getLogId));
|
|
|
|
|
|
for (LogHistoryInfoVO vo : voList) {
|
|
|
User user = userMap.get(vo.getUserId());
|
|
@@ -92,6 +95,8 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
vo.setLogTitle(user.getRealName() + "的日志");
|
|
|
vo.setHeadPicture(StringUtils.isNotEmpty(user.getAvatar()) ? user.getAvatar() : "");
|
|
|
}
|
|
|
+
|
|
|
+ //当前用户是否已读
|
|
|
String readIndex = SecureUtil.getUserId() + vo.getId() + "";
|
|
|
LogHistoryInfoReadVO readVO = readMap.get(readIndex);
|
|
|
if (readVO != null) {
|
|
@@ -99,6 +104,17 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
} else {
|
|
|
vo.setIsRead(0);
|
|
|
}
|
|
|
+
|
|
|
+ //所有已读人
|
|
|
+ List<LogHistoryInfoReadVO> readVOList = logRecords.getOrDefault(vo.getId(), null);
|
|
|
+ if (readVOList != null && readVOList.size() > 0) {
|
|
|
+ List<LogHistoryInfoVO.ReadUser> readUserList = new LinkedList<>();
|
|
|
+ for (LogHistoryInfoReadVO readUsers : readVOList) {
|
|
|
+ LogHistoryInfoVO.ReadUser readUser = new LogHistoryInfoVO.ReadUser(userMap.get(readUsers.getUserId()).getAvatar(), userMap.get(readUsers.getUserId()).getName());
|
|
|
+ readUserList.add(readUser);
|
|
|
+ }
|
|
|
+ vo.setReadUsers(readUserList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return voList.stream()
|
|
@@ -135,28 +151,36 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
|
}
|
|
|
-
|
|
|
- //判断今日是否已填写日志信息
|
|
|
- LocalDate currentDate = LocalDate.now();
|
|
|
- String formattedDate = currentDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
- LogHistoryInfo logOne = baseMapper.selectOne(Wrappers.<LogHistoryInfo>lambdaQuery()
|
|
|
- .select(LogHistoryInfo::getId)
|
|
|
- .eq(LogHistoryInfo::getUserId, SecureUtil.getUserId())
|
|
|
- .like(LogHistoryInfo::getCreateTime, formattedDate));
|
|
|
- if (logOne != null) {
|
|
|
- throw new ServiceException("当前用户今日已填写过日志信息,请勿重复提交");
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getDeptId())) {
|
|
|
+ throw new ServiceException("获取部门信息失败,请联系管理员");
|
|
|
}
|
|
|
-
|
|
|
- dto.setUserId(SecureUtil.getUserId());
|
|
|
-
|
|
|
- //新增
|
|
|
if (ObjectUtil.isEmpty(dto.getId())) {
|
|
|
+ //判断今日是否已填写日志信息
|
|
|
+ LocalDate currentDate = LocalDate.now();
|
|
|
+ String formattedDate = currentDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ List<LogHistoryInfo> logHistoryInfos = baseMapper.selectList(Wrappers.<LogHistoryInfo>lambdaQuery()
|
|
|
+ .select(LogHistoryInfo::getId)
|
|
|
+ .eq(LogHistoryInfo::getUserId, SecureUtil.getUserId())
|
|
|
+ .like(LogHistoryInfo::getCreateTime, formattedDate));
|
|
|
+ if (logHistoryInfos != null && logHistoryInfos.size() > 0) {
|
|
|
+ throw new ServiceException("当前用户今日已填写过日志信息,请勿重复提交");
|
|
|
+ }
|
|
|
+ dto.setUserId(SecureUtil.getUserId());
|
|
|
+ String deptIds = SecureUtil.getDeptId();
|
|
|
+ List<String> strings = Func.toStrList(deptIds);
|
|
|
+ if (strings.size() > 0) {
|
|
|
+ dto.setOrgDept(Long.parseLong(strings.get(0))); //默认选择第一个部门
|
|
|
+ }
|
|
|
+ //新增
|
|
|
if (this.save(dto)) {
|
|
|
- //获取当天,当前用户所有的计划任务信息
|
|
|
+
|
|
|
+ //获取当天,当前用户所有的计划任务信息,新增关联信息
|
|
|
List<TaskPlanInfoVO> taskPlanInfoVOS = this.logTaskList();
|
|
|
- jdbcTemplate.execute("delete from c_log_history_task_record where log_id = " + dto.getId());
|
|
|
- for (TaskPlanInfoVO task : taskPlanInfoVOS) {
|
|
|
- jdbcTemplate.execute("insert into c_log_history_task_record(id,log_id,task_id) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + task.getId() + ")");
|
|
|
+ if (taskPlanInfoVOS.size() > 0) {
|
|
|
+ jdbcTemplate.execute("delete from c_log_history_task_record where log_id = " + dto.getId());
|
|
|
+ for (TaskPlanInfoVO task : taskPlanInfoVOS) {
|
|
|
+ jdbcTemplate.execute("insert into c_log_history_task_record(id,log_id,task_id) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + task.getId() + ")");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//报销金额不为空,在财务报销里新增一条草稿内容
|
|
@@ -177,9 +201,24 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- //编辑
|
|
|
} else {
|
|
|
+ //判断是否是本人操作
|
|
|
+ LogHistoryInfo logHistoryInfo = baseMapper.selectById(dto.getId());
|
|
|
+ if (logHistoryInfo != null && !logHistoryInfo.getCreateUser().equals(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("暂无权限,不能编辑别人的日志信息");
|
|
|
+ }
|
|
|
+ //编辑
|
|
|
if (baseMapper.updateById(dto) > 0) {
|
|
|
+
|
|
|
+ //获取当天,当前用户所有的计划任务信息,新增关联信息
|
|
|
+ List<TaskPlanInfoVO> taskPlanInfoVOS = this.logTaskList();
|
|
|
+ if (taskPlanInfoVOS.size() > 0) {
|
|
|
+ jdbcTemplate.execute("delete from c_log_history_task_record where log_id = " + dto.getId());
|
|
|
+ for (TaskPlanInfoVO task : taskPlanInfoVOS) {
|
|
|
+ jdbcTemplate.execute("insert into c_log_history_task_record(id,log_id,task_id) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + task.getId() + ")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//报销金额不为空,修改财务报销信息
|
|
|
if (ObjectUtil.isNotEmpty(dto.getExpenseReimbursementAmount()) && ObjectUtil.isNotEmpty(dto.getTaskId())) {
|
|
|
ProjectCostBudget projectCostBudget = projectCostBudgetServiceImpl.getBaseMapper().selectOne(Wrappers.<ProjectCostBudget>lambdaQuery().select(ProjectCostBudget::getProjectId).eq(ProjectCostBudget::getId, dto.getTaskId()));
|
|
@@ -244,8 +283,13 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
//获取当前日志关联的任务信息
|
|
|
List<LogHistoryAndTaskVO> taskVOList = jdbcTemplate.query("select * from c_log_history_task_record where log_id = " + id, new BeanPropertyRowMapper<>(LogHistoryAndTaskVO.class));
|
|
|
List<ControlProjectInfo> controlProjectInfos = projectInfoServiceImpl.getBaseMapper().selectList(Wrappers.<ControlProjectInfo>lambdaQuery().select(ControlProjectInfo::getId, ControlProjectInfo::getName));
|
|
|
- List<Long> taskIds = taskVOList.stream().map(LogHistoryAndTaskVO::getTaskId).collect(Collectors.toList());
|
|
|
+ List<String> taskIds = taskVOList.stream().map(LogHistoryAndTaskVO::getTaskId).map(String::valueOf).collect(Collectors.toList());
|
|
|
if (taskIds.size() > 0) {
|
|
|
+ //获取所有审批任务与计划任务关系
|
|
|
+ List<ExpenseTaskRecord> expenseTaskRecords = jdbcTemplate.query("select task_id,expense_info_id from c_expense_task_record where expense_info_type = 1 and expense_info_id in(" + StringUtils.join(taskIds, ",") + ")", new BeanPropertyRowMapper<>(ExpenseTaskRecord.class));
|
|
|
+ Map<String, ExpenseTaskRecord> taskRecordMaps = expenseTaskRecords.stream().collect(Collectors.toMap(ExpenseTaskRecord::getExpenseInfoId, Function.identity()));
|
|
|
+
|
|
|
+ //预算任务集合
|
|
|
List<ProjectCostBudget> taskObjs = projectCostBudgetServiceImpl.listByIds(taskIds);
|
|
|
List<TaskPlanInfoVO> resultList = new ArrayList<>();
|
|
|
for (ProjectCostBudget taskObj : taskObjs) {
|
|
@@ -257,7 +301,20 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- vos.setStatusName(taskObj.getStatus().equals(4) ? "已完成" : "未完成");
|
|
|
+
|
|
|
+ ExpenseTaskRecord record = taskRecordMaps.getOrDefault(String.valueOf(taskObj.getId()), null);
|
|
|
+ if (record != null) {
|
|
|
+ TaskProcessInfo task = jdbcTemplate.query("select status from c_task_process_info where id = " + record.getTaskId(), new BeanPropertyRowMapper<>(TaskProcessInfo.class)).stream().findAny().orElse(null);
|
|
|
+ if (task != null) {
|
|
|
+ vos.setStatus(task.getStatus().equals(1) ? 1 : (task.getStatus().equals(2) ? 2 : (task.getStatus().equals(3) ? 3 : 0)));
|
|
|
+ vos.setStatusName(task.getStatus().equals(1) ? "待审批" : (task.getStatus().equals(2) ? "已审批" : (task.getStatus().equals(3) ? "已驳回" : "未提交审批")));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(vos.getStatusName())) {
|
|
|
+ vos.setStatus(0);
|
|
|
+ vos.setStatusName("未提交审批");
|
|
|
+ }
|
|
|
+
|
|
|
vos.setTaskDesc(ObjectUtil.isNotEmpty(taskObj.getPlanTaskDesc()) ? taskObj.getPlanTaskDesc() : "");
|
|
|
if (ObjectUtil.isNotEmpty(taskObj.getPlanStartTime()) && ObjectUtil.isNotEmpty(taskObj.getPlanEndTime())) {
|
|
|
LocalDate planStartTime = taskObj.getPlanStartTime();
|
|
@@ -300,6 +357,10 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
|
|
|
@Override
|
|
|
public boolean logTaskComplete(Long logId, Long taskId) {
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
ProjectCostBudget task = projectCostBudgetServiceImpl.getBaseMapper().selectById(taskId);
|
|
|
if (ObjectUtil.isEmpty(task.getDeptId())) {
|
|
|
throw new ServiceException("获取部门信息失败,请联系管理员");
|
|
@@ -309,43 +370,58 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
User departmentHead = taskProcessService.getDepartmentHead(task.getDeptId());
|
|
|
if (departmentHead != null) {
|
|
|
//修改计划任务的状态为已完成
|
|
|
- boolean updated = projectCostBudgetServiceImpl.update(Wrappers.<ProjectCostBudget>lambdaUpdate().set(ProjectCostBudget::getStatus, 4).eq(ProjectCostBudget::getId, taskId));
|
|
|
- if (updated) {
|
|
|
- //新增审批任务
|
|
|
- TaskProcessInfo taskProcessInfo = new TaskProcessInfo();
|
|
|
- taskProcessInfo.setId(SnowFlakeUtil.getId());
|
|
|
- taskProcessInfo.setStatus(1); //待审批
|
|
|
- taskProcessInfo.setReportDate(new Date());
|
|
|
- taskProcessInfo.setTaskType(1); //任务审批
|
|
|
- taskProcessInfo.setTaskName("【" + SecureUtil.getUserName() + "】向您发起【任务审批】审批");
|
|
|
-
|
|
|
- //上报人
|
|
|
- taskProcessInfo.setReportUserId(SecureUtil.getUserId());
|
|
|
-
|
|
|
- //审批人
|
|
|
- List<String> auditUserIds = new LinkedList<>();
|
|
|
- auditUserIds.add(departmentHead.getId() + "");
|
|
|
-
|
|
|
- List<String> nonEmptyAuditUserIds = new LinkedList<>();
|
|
|
- for (String userId : auditUserIds) {
|
|
|
- if (StringUtils.isNotEmpty(userId)) {
|
|
|
- nonEmptyAuditUserIds.add(userId);
|
|
|
+ ProjectCostBudget obj = projectCostBudgetServiceImpl.getById(taskId);
|
|
|
+ if (obj != null && !obj.getTaskUser().equals(SecureUtil.getUserId())) {
|
|
|
+ throw new ServiceException("该任务不属于当前用户,操作失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取当天,当前用户所有的计划任务信息,新增关联信息
|
|
|
+ if (ObjectUtil.isNotEmpty(logId)) { //编辑时,点完成,那么重塑关系信息
|
|
|
+ List<TaskPlanInfoVO> taskPlanInfoVOS = this.logTaskList();
|
|
|
+ if (taskPlanInfoVOS.size() > 0) {
|
|
|
+ jdbcTemplate.execute("delete from c_log_history_task_record where log_id = " + logId);
|
|
|
+ for (TaskPlanInfoVO taskPlanInfoVO : taskPlanInfoVOS) {
|
|
|
+ jdbcTemplate.execute("insert into c_log_history_task_record(id,log_id,task_id) values(" + SnowFlakeUtil.getId() + "," + logId + "," + taskPlanInfoVO.getId() + ")");
|
|
|
}
|
|
|
}
|
|
|
- if (nonEmptyAuditUserIds.size() == 0) {
|
|
|
- taskProcessInfo.setAuditUserIds(null);
|
|
|
- } else {
|
|
|
- taskProcessInfo.setAuditUserIds(StringUtils.join(nonEmptyAuditUserIds, ","));
|
|
|
+ }
|
|
|
+
|
|
|
+ //新增审批任务
|
|
|
+ TaskProcessInfo taskProcessInfo = new TaskProcessInfo();
|
|
|
+ taskProcessInfo.setId(SnowFlakeUtil.getId());
|
|
|
+ taskProcessInfo.setStatus(1); //待审批
|
|
|
+ taskProcessInfo.setReportDate(new Date());
|
|
|
+ taskProcessInfo.setTaskType(1); //任务审批
|
|
|
+ taskProcessInfo.setTaskName("【" + SecureUtil.getUserName() + "】向您发起【任务审批】审批");
|
|
|
+
|
|
|
+ //上报人
|
|
|
+ taskProcessInfo.setReportUserId(SecureUtil.getUserId());
|
|
|
+
|
|
|
+ //审批人
|
|
|
+ List<String> auditUserIds = new LinkedList<>();
|
|
|
+ auditUserIds.add(departmentHead.getId() + "");
|
|
|
+
|
|
|
+ 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, ","));
|
|
|
+ }
|
|
|
|
|
|
- taskProcessService.save(taskProcessInfo);
|
|
|
+ taskProcessService.save(taskProcessInfo);
|
|
|
|
|
|
- //新增审批任务关联信息
|
|
|
- jdbcTemplate.execute("delete from c_expense_task_record where task_id = " + taskProcessInfo.getId() + " and expense_info_id = " + task.getId() + " ; insert into c_expense_task_record(id,task_id,expense_info_id,expense_info_type) values (" + SnowFlakeUtil.getId() + "," + taskProcessInfo.getId() + "," + task.getId() + ",1)");
|
|
|
- return true;
|
|
|
- }
|
|
|
+ //新增审批任务关联信息
|
|
|
+ jdbcTemplate.execute("delete from c_expense_task_record where task_id = " + taskProcessInfo.getId() + " and expense_info_id = " + task.getId() + " ; insert into c_expense_task_record(id,task_id,expense_info_id,expense_info_type) values (" + SnowFlakeUtil.getId() + "," + taskProcessInfo.getId() + "," + task.getId() + ",1)");
|
|
|
+ return true;
|
|
|
+ //}
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("获取部门负责人失败,请联系管理员");
|
|
|
}
|
|
|
- return false;
|
|
|
}
|
|
|
|
|
|
@Override
|