|
@@ -2,10 +2,12 @@ package org.springblade.control.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.apache.commons.lang.time.DateUtils;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
|
+import org.springblade.control.dto.EMFinancialReimbursementInfoDTO;
|
|
import org.springblade.control.dto.LogHistoryInfoDTO;
|
|
import org.springblade.control.dto.LogHistoryInfoDTO;
|
|
import org.springblade.control.entity.LogHistoryInfo;
|
|
import org.springblade.control.entity.LogHistoryInfo;
|
|
import org.springblade.control.mapper.LogHistoryMapper;
|
|
import org.springblade.control.mapper.LogHistoryMapper;
|
|
@@ -17,6 +19,7 @@ import org.springblade.core.mp.base.BaseServiceImpl;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
import org.springblade.core.tool.utils.DateUtil;
|
|
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.entity.User;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@@ -36,6 +39,7 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
|
|
|
|
private final IUserClient iUserClient;
|
|
private final IUserClient iUserClient;
|
|
private final JdbcTemplate jdbcTemplate;
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
+ private final EMFinancialReimbursementServiceImpl emFinancialReimbursementService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, List<LogHistoryInfoVO>> logList(LogHistoryInfoDTO dto) {
|
|
public Map<String, List<LogHistoryInfoVO>> logList(LogHistoryInfoDTO dto) {
|
|
@@ -48,17 +52,17 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
}
|
|
}
|
|
if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
if (StringUtils.isNotEmpty(dto.getStartTime()) && StringUtils.isNotEmpty(dto.getEndTime())) {
|
|
String endTime = dto.getEndTime();
|
|
String endTime = dto.getEndTime();
|
|
- endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM-dd"), 1), "yyyy-MM-dd");
|
|
|
|
|
|
+ endTime = DateUtil.format(DateUtils.addDays(DateUtil.parse(endTime, "yyyy-MM"), 1), "yyyy-MM");
|
|
queryWrapper.between(LogHistoryInfo::getCreateTime, dto.getStartTime(), endTime);
|
|
queryWrapper.between(LogHistoryInfo::getCreateTime, dto.getStartTime(), endTime);
|
|
} else {
|
|
} else {
|
|
- //默认查询7天内日志
|
|
|
|
|
|
+ //默认查询当月所有日志
|
|
LocalDate today = LocalDate.now();
|
|
LocalDate today = LocalDate.now();
|
|
- LocalDate tomorrow = today.plusDays(1);
|
|
|
|
- LocalDate sevenDaysAgo = today.minusDays(6);
|
|
|
|
|
|
+ LocalDate firstDayOfMonth = today.withDayOfMonth(1);
|
|
|
|
+ LocalDate lastDayOfMonth = today.withDayOfMonth(today.lengthOfMonth());
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
- String todayStr = tomorrow.format(formatter);
|
|
|
|
- String sevenDaysAgoStr = sevenDaysAgo.format(formatter);
|
|
|
|
- queryWrapper.between(LogHistoryInfo::getCreateTime, sevenDaysAgoStr, todayStr);
|
|
|
|
|
|
+ String firstDayOfMonthStr = firstDayOfMonth.format(formatter);
|
|
|
|
+ String lastDayOfMonthStr = lastDayOfMonth.format(formatter);
|
|
|
|
+ queryWrapper.between(LogHistoryInfo::getCreateTime, firstDayOfMonthStr, lastDayOfMonthStr);
|
|
}
|
|
}
|
|
queryWrapper.orderByDesc(true, LogHistoryInfo::getCreateTime);
|
|
queryWrapper.orderByDesc(true, LogHistoryInfo::getCreateTime);
|
|
List<LogHistoryInfo> logHistoryInfos = baseMapper.selectList(queryWrapper);
|
|
List<LogHistoryInfo> logHistoryInfos = baseMapper.selectList(queryWrapper);
|
|
@@ -71,7 +75,8 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
for (User user : userList) {
|
|
for (User user : userList) {
|
|
userMap.put(user.getId(), user);
|
|
userMap.put(user.getId(), user);
|
|
}
|
|
}
|
|
- //7天内已读日志记录信息
|
|
|
|
|
|
+
|
|
|
|
+ //当月内已读日志记录信息
|
|
List<LogHistoryInfoReadVO> infoReadVOS = jdbcTemplate.query("select * from c_log_history_read_record where log_id in(" + StringUtils.join(logIds, ",") + ")", new BeanPropertyRowMapper<>(LogHistoryInfoReadVO.class));
|
|
List<LogHistoryInfoReadVO> infoReadVOS = jdbcTemplate.query("select * from c_log_history_read_record where log_id in(" + StringUtils.join(logIds, ",") + ")", new BeanPropertyRowMapper<>(LogHistoryInfoReadVO.class));
|
|
Map<String, LogHistoryInfoReadVO> readMap = new HashMap<>();
|
|
Map<String, LogHistoryInfoReadVO> readMap = new HashMap<>();
|
|
for (LogHistoryInfoReadVO readVO : infoReadVOS) {
|
|
for (LogHistoryInfoReadVO readVO : infoReadVOS) {
|
|
@@ -92,36 +97,63 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
vo.setIsRead(0);
|
|
vo.setIsRead(0);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return voList.stream()
|
|
|
|
+ .collect(Collectors.groupingBy(vo -> {
|
|
|
|
+ LocalDateTime localDateTime = LocalDateTime.ofInstant(vo.getCreateTime().toInstant(), ZoneId.systemDefault());
|
|
|
|
+ return localDateTime.toLocalDate().toString();
|
|
|
|
+ }, LinkedHashMap::new, Collectors.toList()));
|
|
}
|
|
}
|
|
- return voList.stream()
|
|
|
|
- .collect(Collectors.groupingBy(vo -> {
|
|
|
|
- LocalDateTime localDateTime = LocalDateTime.ofInstant(vo.getCreateTime().toInstant(), ZoneId.systemDefault());
|
|
|
|
- return localDateTime.toLocalDate().toString();
|
|
|
|
- }, LinkedHashMap::new, Collectors.toList()));
|
|
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean logSubmit(LogHistoryInfoDTO dto) {
|
|
public boolean logSubmit(LogHistoryInfoDTO dto) {
|
|
- if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
}
|
|
}
|
|
- dto.setUserId(SecureUtil.getUserId());
|
|
|
|
- this.saveOrUpdate(dto);
|
|
|
|
|
|
|
|
- if (ObjectUtil.isNotEmpty(dto.getTaskIds())){
|
|
|
|
- //新增日志与任务关系信息 TODO
|
|
|
|
|
|
+ //判断今日是否已填写日志信息
|
|
|
|
+ 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.isNotEmpty(dto.getExpenseReimbursementAmount())) {
|
|
|
|
- //报销金额不为空,在财务报销里面新增一条草稿箱内容 TODO
|
|
|
|
- }
|
|
|
|
|
|
+ //入库
|
|
|
|
+ dto.setUserId(SecureUtil.getUserId());
|
|
|
|
+ if (this.saveOrUpdate(dto)) {
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getTaskIds())) {
|
|
|
|
+ //新增日志与计划任务关系信息
|
|
|
|
+ List<String> taskIds = Func.toStrList(dto.getTaskIds());
|
|
|
|
+ for (String taskId : taskIds) {
|
|
|
|
+ jdbcTemplate.execute("insert into c_log_history_task_record(id,log_id,task_id) values(" + SnowFlakeUtil.getId() + "," + dto.getId() + "," + taskId + ")");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getExpenseReimbursementAmount())) {
|
|
|
|
+ //报销金额不为空,在财务报销里新增一条草稿内容
|
|
|
|
+ EMFinancialReimbursementInfoDTO infoDTO = new EMFinancialReimbursementInfoDTO();
|
|
|
|
+ infoDTO.setSubmitStatus("1"); //暂存
|
|
|
|
+ infoDTO.setFrDate(new Date()); //当前时间
|
|
|
|
+ infoDTO.setProjectId(null); //TODO 从日志勾选的任务获取
|
|
|
|
+ infoDTO.setBudgetPlanIds(null);
|
|
|
|
+ infoDTO.setFrType(1); //差旅费
|
|
|
|
+ infoDTO.setUserIdVesting(SecureUtil.getUserId()); //归属人
|
|
|
|
+ infoDTO.setFrMoney(dto.getExpenseReimbursementAmount()); //报销金额
|
|
|
|
+ emFinancialReimbursementService.financialSubmit(infoDTO);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public LogHistoryInfoVO logDetail(Long id) {
|
|
public LogHistoryInfoVO logDetail(Long id) {
|
|
- if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
|
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
}
|
|
}
|
|
LogHistoryInfo obj = baseMapper.selectById(id);
|
|
LogHistoryInfo obj = baseMapper.selectById(id);
|
|
@@ -134,16 +166,18 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
vo.setHeadPicture(StringUtils.isNotEmpty(user.getAvatar()) ? user.getAvatar() : "");
|
|
vo.setHeadPicture(StringUtils.isNotEmpty(user.getAvatar()) ? user.getAvatar() : "");
|
|
}
|
|
}
|
|
|
|
|
|
- //处理当前用户查看当前日志信息为已读状态
|
|
|
|
- Long row = jdbcTemplate.queryForObject("select count(1) from c_log_history_read_record where log_id = " + vo.getId() + " and user_id = " + SecureUtil.getUserId(), Long.class);
|
|
|
|
- if (row == null || row == 0L) {
|
|
|
|
- jdbcTemplate.execute("insert into c_log_history_read_record(id,log_id,user_id) values (" + SnowFlakeUtil.getId() + "," + vo.getId() + "," + SecureUtil.getUserId() + ")");
|
|
|
|
- vo.setIsRead(1);
|
|
|
|
|
|
+ //处理当前用户查看当前日志信息为已读状态(只有不是自己的日志才添加已读记录信息)
|
|
|
|
+ if (!obj.getUserId().equals(SecureUtil.getUserId())) {
|
|
|
|
+ Long row = jdbcTemplate.queryForObject("select count(1) from c_log_history_read_record where log_id = " + vo.getId() + " and user_id = " + SecureUtil.getUserId(), Long.class);
|
|
|
|
+ if (row == null || row == 0L) {
|
|
|
|
+ jdbcTemplate.execute("insert into c_log_history_read_record(id,log_id,user_id) values (" + SnowFlakeUtil.getId() + "," + vo.getId() + "," + SecureUtil.getUserId() + ")");
|
|
|
|
+ vo.setIsRead(1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- //处理当前日志taskList任务列表 TODO
|
|
|
|
|
|
+ //TODO 处理当前日志的 计划任务List
|
|
|
|
|
|
- //处理所有已读人信息
|
|
|
|
|
|
+ //处理当前日志所有已读人信息
|
|
List<LogHistoryInfoReadVO> readUsersInfo = jdbcTemplate.query("select * from c_log_history_read_record where log_id = " + vo.getId(), new BeanPropertyRowMapper<>(LogHistoryInfoReadVO.class));
|
|
List<LogHistoryInfoReadVO> readUsersInfo = jdbcTemplate.query("select * from c_log_history_read_record where log_id = " + vo.getId(), new BeanPropertyRowMapper<>(LogHistoryInfoReadVO.class));
|
|
List<Long> userIds = readUsersInfo.stream().map(LogHistoryInfoReadVO::getUserId).distinct().collect(Collectors.toList());
|
|
List<Long> userIds = readUsersInfo.stream().map(LogHistoryInfoReadVO::getUserId).distinct().collect(Collectors.toList());
|
|
if (userIds.size() > 0) {
|
|
if (userIds.size() > 0) {
|
|
@@ -161,13 +195,30 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public boolean logRemove(Long id) {
|
|
|
|
+ if (ObjectUtil.isEmpty(SecureUtil.getUser())) {
|
|
|
|
+ throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
|
|
+ }
|
|
|
|
+ LogHistoryInfo logHistoryInfo = baseMapper.selectById(id);
|
|
|
|
+ if (logHistoryInfo != null && !logHistoryInfo.getUserId().equals(SecureUtil.getUserId())) {
|
|
|
|
+ throw new ServiceException("只能删除自己编写的日志,操作失败");
|
|
|
|
+ }
|
|
|
|
+ if (this.removeById(id)) {
|
|
|
|
+ //删除关联信息、已读信息
|
|
|
|
+ jdbcTemplate.execute("delete from c_log_history_task_record where log_id = " + id);
|
|
|
|
+ jdbcTemplate.execute("delete from c_log_history_read_record where log_id = " + id);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public boolean logTaskComplete(Long logId, Long taskId) {
|
|
public boolean logTaskComplete(Long logId, Long taskId) {
|
|
if (ObjectUtil.isEmpty(logId)) {
|
|
if (ObjectUtil.isEmpty(logId)) {
|
|
- throw new ServiceException("请先提交日志后,再变更任务");
|
|
|
|
|
|
+ throw new ServiceException("请先提交日志后,再变更任务状态");
|
|
}
|
|
}
|
|
- //修改计划任务的状态为已完成,推送到对应的当前部门负责人审批(此处修改的任务状态为计划任务,新增推送的任务为审批任务) TODO
|
|
|
|
-
|
|
|
|
|
|
+ //TODO 修改计划任务的状态为已完成,新增一条审批任务到对应的当前部门的负责人审批(此处修改的任务状态是计划任务的,新增推送的任务是审批任务的)
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -176,8 +227,8 @@ public class LogHistoryServiceImpl extends BaseServiceImpl<LogHistoryMapper, Log
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUserId())) {
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
throw new ServiceException("获取当前用户信息失败,请联系管理员");
|
|
}
|
|
}
|
|
- //获取当前用户当天的所有任务信息 TODO
|
|
|
|
-
|
|
|
|
|
|
+ //TODO 获取当前用户当天的所有任务信息
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|