feature-zrx #32
|
@ -16,7 +16,7 @@ import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -65,10 +65,18 @@ public class ProjectDailyController {
|
||||||
@GetMapping("/daily/search")
|
@GetMapping("/daily/search")
|
||||||
public BaseResponse searchMyDaily(@RequestParam Integer page,
|
public BaseResponse searchMyDaily(@RequestParam Integer page,
|
||||||
@RequestParam Integer pageSize,
|
@RequestParam Integer pageSize,
|
||||||
Date beginTime,
|
Integer projectId,
|
||||||
Date endTime,
|
String beginTime,
|
||||||
|
String endTime,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
return projectDailyService.searchMyDaily(page, pageSize, beginTime, endTime, request);
|
|
||||||
|
|
||||||
|
return projectDailyService.searchMyDaily(projectId,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
Processing.convertStringToDate(beginTime),
|
||||||
|
Processing.convertStringToDate(endTime),
|
||||||
|
request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -58,6 +60,42 @@ public class ProjectDailyDAO {
|
||||||
List<ProjectDailyDO> myProjectDaily = projectDailyMapper.getProjectDailyByUser(userId);
|
List<ProjectDailyDO> myProjectDaily = projectDailyMapper.getProjectDailyByUser(userId);
|
||||||
projectDailyDOList.addAll(myProjectDaily);
|
projectDailyDOList.addAll(myProjectDaily);
|
||||||
|
|
||||||
|
// 排序并去重
|
||||||
|
projectDailyDOList = sortaAndNotRepeatDailyDO(projectDailyDOList);
|
||||||
|
|
||||||
|
return projectDailyDOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<ProjectDailyDO> getMyProjectDailyByTime(Long userId, Date beginTime, Date endTime) {
|
||||||
|
|
||||||
|
// 日报数据数组
|
||||||
|
List<ProjectDailyDO> projectDailyDOList = new ArrayList<>();
|
||||||
|
|
||||||
|
// 先获取我负责的项目下的日报数据
|
||||||
|
//获取我负责的项目
|
||||||
|
List<ProjectDO> projectDOS = projectMapper.getAllProjectByUserId(userId);
|
||||||
|
//获取项目下对应日报,并根据时间筛选
|
||||||
|
for (ProjectDO projectDO:projectDOS) {
|
||||||
|
List dailyFromProject = projectDailyMapper.getProjectDailyByProjectAndTime(projectDO.getId(),
|
||||||
|
beginTime, endTime);
|
||||||
|
projectDailyDOList.addAll(dailyFromProject);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 在获取本人的发布日报,并根据时间筛选
|
||||||
|
List<ProjectDailyDO> myProjectDaily = projectDailyMapper.
|
||||||
|
getProjectDailyByUserAndTime(userId, beginTime, endTime);
|
||||||
|
projectDailyDOList.addAll(myProjectDaily);
|
||||||
|
|
||||||
|
// 排序并去重
|
||||||
|
projectDailyDOList = sortaAndNotRepeatDailyDO(projectDailyDOList);
|
||||||
|
|
||||||
|
return projectDailyDOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<ProjectDailyDO> sortaAndNotRepeatDailyDO(List<ProjectDailyDO> projectDailyDOList) {
|
||||||
|
|
||||||
// 去除重复的日报信息
|
// 去除重复的日报信息
|
||||||
projectDailyDOList = projectDailyDOList.stream()
|
projectDailyDOList = projectDailyDOList.stream()
|
||||||
// 根据 id 属性进行去重
|
// 根据 id 属性进行去重
|
||||||
|
@ -66,12 +104,13 @@ public class ProjectDailyDAO {
|
||||||
.values().stream()
|
.values().stream()
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 根据时间进行排序
|
||||||
|
projectDailyDOList = projectDailyDOList.stream()
|
||||||
|
.sorted(Comparator.comparing(ProjectDailyDO::getCreatedAt).reversed())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
return projectDailyDOList;
|
return projectDailyDOList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ package com.jsl.oa.mapper;
|
||||||
import com.jsl.oa.model.dodata.ProjectDailyDO;
|
import com.jsl.oa.model.dodata.ProjectDailyDO;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,6 +24,9 @@ public interface ProjectDailyMapper {
|
||||||
|
|
||||||
List<ProjectDailyDO> getProjectDailyByProject(Long pid);
|
List<ProjectDailyDO> getProjectDailyByProject(Long pid);
|
||||||
|
|
||||||
|
List getProjectDailyByProjectAndTime(Long id, Date beginTime, Date endTime);
|
||||||
|
|
||||||
|
List<ProjectDailyDO> getProjectDailyByUserAndTime(Long userId, Date beginTime, Date endTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,8 @@ public interface ProjectDailyService {
|
||||||
|
|
||||||
BaseResponse getMyDaily(Integer page, Integer pageSize, HttpServletRequest request);
|
BaseResponse getMyDaily(Integer page, Integer pageSize, HttpServletRequest request);
|
||||||
|
|
||||||
BaseResponse searchMyDaily(Integer page,
|
BaseResponse searchMyDaily(Integer projectId,
|
||||||
|
Integer page,
|
||||||
Integer pageSize,
|
Integer pageSize,
|
||||||
Date beginTime,
|
Date beginTime,
|
||||||
Date endTime,
|
Date endTime,
|
||||||
|
|
|
@ -88,19 +88,40 @@ public class ProjectDailyServiceImpl implements ProjectDailyService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseResponse searchMyDaily(Integer page,
|
public BaseResponse searchMyDaily(Integer projectId,
|
||||||
|
Integer page,
|
||||||
Integer pageSize,
|
Integer pageSize,
|
||||||
Date beginTime,
|
Date beginTime,
|
||||||
Date endTime,
|
Date endTime,
|
||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
// 获取用户id
|
// 获取用户id
|
||||||
Long userId = Processing.getAuthHeaderToUserId(request);
|
Long userId = Processing.getAuthHeaderToUserId(request);
|
||||||
// 获取 我发布的及自己负责的项目下 的日报
|
|
||||||
List<ProjectDailyDO> projectDailyDOList =
|
// 根据时间筛选---获取 我发布的及自己负责的项目下 的日报
|
||||||
|
List<ProjectDailyDO> projectDailyDOList = new ArrayList<>();
|
||||||
|
//如果时间不为空,则先根据时间筛选
|
||||||
|
if (beginTime != null && endTime != null) {
|
||||||
|
projectDailyDOList = projectDailyDAO.
|
||||||
|
getMyProjectDailyByTime(userId, beginTime, endTime);
|
||||||
|
} else {
|
||||||
|
//否则获取全部数据
|
||||||
|
projectDailyDOList =
|
||||||
projectDailyDAO.getMyProjectDaily(userId);
|
projectDailyDAO.getMyProjectDaily(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 再根据项目id进行筛选
|
||||||
|
if (projectId != null) {
|
||||||
|
projectDailyDOList.removeIf(projectDailyDO -> projectDailyDO.getProjectId() != Long.valueOf(projectId));
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
// 进行分页
|
||||||
|
List<ProjectDailyDO> dailyPage = Processing.getPage(projectDailyDOList, page, pageSize);
|
||||||
|
// 封装结果类
|
||||||
|
List<ProjectDailyVO> projectDailyVOS = encapsulateArrayClass(dailyPage);
|
||||||
|
ProjectDailyDataVO projectDailyDataVO =
|
||||||
|
new ProjectDailyDataVO(projectDailyDOList.size(), page, pageSize, projectDailyVOS);
|
||||||
|
|
||||||
|
return ResultUtil.success(projectDailyDataVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,9 @@ import org.springframework.validation.ObjectError;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.text.ParseException;
|
||||||
import java.util.Comparator;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <h1>自定义快捷工具类</h1>
|
* <h1>自定义快捷工具类</h1>
|
||||||
|
@ -409,4 +408,26 @@ public class Processing {
|
||||||
int toIndex = Math.min(fromIndex + pageSize, list.size());
|
int toIndex = Math.min(fromIndex + pageSize, list.size());
|
||||||
return list.subList(fromIndex, toIndex);
|
return list.subList(fromIndex, toIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description: 字符与时间类型转换方法
|
||||||
|
* @Date: 2024/4/19
|
||||||
|
* @Param dateString:
|
||||||
|
**/
|
||||||
|
public static Date convertStringToDate(String dateString) {
|
||||||
|
if (dateString.isEmpty()) {
|
||||||
|
return null; // 如果字符串为空,返回空的Date对象
|
||||||
|
} else {
|
||||||
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
try {
|
||||||
|
return dateFormat.parse(dateString);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,5 +37,20 @@
|
||||||
and is_delete = 0
|
and is_delete = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getProjectDailyByProjectAndTime" parameterType="java.util.Map"
|
||||||
|
resultType="com.jsl.oa.model.dodata.ProjectDailyDO">
|
||||||
|
select * from oa_project_daily
|
||||||
|
where project_id = #{id}
|
||||||
|
and created_at between #{beginTime} and #{endTime}
|
||||||
|
and is_delete = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getProjectDailyByUserAndTime" parameterType="java.util.Map"
|
||||||
|
resultType="com.jsl.oa.model.dodata.ProjectDailyDO">
|
||||||
|
select * from oa_project_daily
|
||||||
|
where user_id = #{userId}
|
||||||
|
and created_at between #{beginTime} and #{endTime}
|
||||||
|
and is_delete = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue
Block a user