|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.datascope.annotation.DataScope;
|
|
|
+import com.ruoyi.common.datascope.context.DataScopeContextHolder;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.core.domain.R;
|
|
|
import com.usky.common.core.exception.BusinessException;
|
|
@@ -179,6 +180,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LocalDateTime endDateTime = null;
|
|
|
LocalDate start = null;
|
|
|
LocalDate end = null;
|
|
|
+ List<PmWorkContent> workContentList = new ArrayList<>();
|
|
|
List<Integer> reportIds = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
|
|
|
DateTimeFormatter formatter = null;
|
|
@@ -194,9 +196,11 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId).between(PmWorkReport::getReportDate, start, end);
|
|
|
reportIds = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toList());
|
|
|
+ if (reportIds.isEmpty()){
|
|
|
+ return workContentList;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- List<PmWorkContent> workContentList = new ArrayList<>();
|
|
|
|
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
contentLambdaQuery.select(PmWorkContent::getProjectId);
|
|
@@ -235,7 +239,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
workContentList = pmWorkContentMapper.selectList(contentLambdaQuery);
|
|
|
|
|
|
List<Integer> workContentIds = workContentList.stream().map(PmWorkContent::getProjectId).distinct().collect(Collectors.toList());
|
|
|
- if (workContentIds.isEmpty()){
|
|
|
+ if (workContentIds.isEmpty()) {
|
|
|
return workContentList;
|
|
|
}
|
|
|
LambdaQueryWrapper<PmProject> projectQuery = Wrappers.lambdaQuery();
|
|
@@ -445,13 +449,16 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId).eq(PmWorkReport::getReportStatus, 1).between(PmWorkReport::getReportDate, start, end);
|
|
|
reportIds = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toList());
|
|
|
+ if (reportIds.isEmpty()){
|
|
|
+ return returnPage;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (projectId != null && projectId > 0) {
|
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
contentLambdaQuery.select(PmWorkContent::getReportId).eq(PmWorkContent::getProjectId, projectId);
|
|
|
reportIds.addAll(pmWorkContentMapper.selectList(contentLambdaQuery).stream().map(PmWorkContent::getReportId).collect(Collectors.toList()));
|
|
|
- if (reportIds.isEmpty()){
|
|
|
+ if (reportIds.isEmpty()) {
|
|
|
return returnPage;
|
|
|
}
|
|
|
}
|
|
@@ -696,15 +703,20 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
return pmProjectMapper.selectList(projectsQuery);
|
|
|
}
|
|
|
|
|
|
+ @DataScope(userAlias = "d")
|
|
|
private List<SysUser> userNameList(Long userId) {
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
LambdaQueryWrapper<SysUser> userNameQuery = Wrappers.lambdaQuery();
|
|
|
- userNameQuery.select(SysUser::getUserId, SysUser::getNickName, SysUser::getUserName, SysUser::getPhonenumber, SysUser::getAvatar, SysUser::getSex, SysUser::getDeptId).eq(SysUser::getDelFlag, 0).eq(SysUser::getStatus, 0);
|
|
|
+ userNameQuery.select(SysUser::getUserId, SysUser::getNickName, SysUser::getUserName, SysUser::getPhonenumber, SysUser::getAvatar,
|
|
|
+ SysUser::getSex, SysUser::getDeptId)
|
|
|
+ .eq(SysUser::getDelFlag, 0)
|
|
|
+ .eq(SysUser::getStatus, 0);
|
|
|
if (userId != null && userId != 0) {
|
|
|
userNameQuery.eq(SysUser::getUserId, userId);
|
|
|
return sysUserMapper.selectList(userNameQuery);
|
|
|
}
|
|
|
+ // userNameQuery.apply(DataScopeContextHolder.getDataScopeSql());
|
|
|
userNameQuery.eq(SysUser::getTenantId, tenantId).eq(SysUser::getDeptId, deptId);
|
|
|
return sysUserMapper.selectList(userNameQuery);
|
|
|
}
|
|
@@ -718,10 +730,13 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
**/
|
|
|
//@DataScope//数据权限注解
|
|
|
private List<PmWorkContent> workTimeCount(List<Long> users, List<Integer> project, String startDate, String endDate) {
|
|
|
+ List<PmWorkContent> pmWorkContentList = new ArrayList<>();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
LambdaQueryWrapper<PmWorkContent> workTimeQuery = Wrappers.lambdaQuery();
|
|
|
- workTimeQuery.select(PmWorkContent::getSubmitterId, PmWorkContent::getReportId, PmWorkContent::getProjectId, PmWorkContent::getProjectName, PmWorkContent::getWorkTime, PmWorkContent::getDeptId, PmWorkContent::getTenantId);
|
|
|
+ workTimeQuery.select(PmWorkContent::getSubmitterId, PmWorkContent::getReportId, PmWorkContent::getProjectId, PmWorkContent::getProjectName,
|
|
|
+ PmWorkContent::getWorkTime, PmWorkContent::getDeptId, PmWorkContent::getTenantId)
|
|
|
+ .eq(PmWorkContent::getTenantId, tenantId).eq(PmWorkContent::getDeptId, deptId);
|
|
|
if (!users.isEmpty()) {
|
|
|
workTimeQuery.in(PmWorkContent::getSubmitterId, users);
|
|
|
}
|
|
@@ -734,11 +749,12 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
List<Integer> reports = reports(start, end);
|
|
|
if (!reports.isEmpty()) {
|
|
|
workTimeQuery.in(PmWorkContent::getReportId, reports);
|
|
|
+ } else {
|
|
|
+ return pmWorkContentList;
|
|
|
}
|
|
|
}
|
|
|
- workTimeQuery.eq(PmWorkContent::getTenantId, tenantId).eq(PmWorkContent::getDeptId, deptId);
|
|
|
// workTimeQuery.apply(DataScopeContextHolder.getDataScopeSql());// 数据权限设置
|
|
|
- List<PmWorkContent> pmWorkContentList = pmWorkContentMapper.selectList(workTimeQuery);
|
|
|
+ pmWorkContentList = pmWorkContentMapper.selectList(workTimeQuery);
|
|
|
|
|
|
Map<String, PmWorkContent> workTimeMap = new HashMap<>();
|
|
|
for (PmWorkContent content : pmWorkContentList) {
|
|
@@ -783,27 +799,29 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
// 统计userId每个项目所需工时
|
|
|
List<WorkHoursStatisticsVO> userAndProject = new ArrayList<>();
|
|
|
List<PmWorkContent> pmWorkContentList = workTimeCount(userIds, pmProjectId, startDate, endDate);
|
|
|
- for (PmWorkContent content : pmWorkContentList) {
|
|
|
- WorkHoursStatisticsVO workHoursStatisticsVO = new WorkHoursStatisticsVO();
|
|
|
- Long submitterId = content.getSubmitterId();
|
|
|
- Integer projectId1 = content.getProjectId();
|
|
|
- BigDecimal workTime = content.getWorkTime();
|
|
|
- workHoursStatisticsVO.setWorkTime(workTime);
|
|
|
- for (SysUser user : users) {
|
|
|
- Long userId1 = user.getUserId();
|
|
|
- String nickName1 = user.getNickName();
|
|
|
- if (userId1.equals(submitterId)) {
|
|
|
- workHoursStatisticsVO.setNickName(nickName1);
|
|
|
+ if (!pmWorkContentList.isEmpty()) {
|
|
|
+ for (PmWorkContent content : pmWorkContentList) {
|
|
|
+ WorkHoursStatisticsVO workHoursStatisticsVO = new WorkHoursStatisticsVO();
|
|
|
+ Long submitterId = content.getSubmitterId();
|
|
|
+ Integer projectId1 = content.getProjectId();
|
|
|
+ BigDecimal workTime = content.getWorkTime();
|
|
|
+ workHoursStatisticsVO.setWorkTime(workTime);
|
|
|
+ for (SysUser user : users) {
|
|
|
+ Long userId1 = user.getUserId();
|
|
|
+ String nickName1 = user.getNickName();
|
|
|
+ if (userId1.equals(submitterId)) {
|
|
|
+ workHoursStatisticsVO.setNickName(nickName1);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- for (PmProject project : pmProjects) {
|
|
|
- Integer projectId2 = project.getId();
|
|
|
- String projectName = project.getProjectName();
|
|
|
- if (projectId2 == projectId1) {
|
|
|
- workHoursStatisticsVO.setProjectName(projectName);
|
|
|
+ for (PmProject project : pmProjects) {
|
|
|
+ Integer projectId2 = project.getId();
|
|
|
+ String projectName = project.getProjectName();
|
|
|
+ if (projectId2 == projectId1) {
|
|
|
+ workHoursStatisticsVO.setProjectName(projectName);
|
|
|
+ }
|
|
|
}
|
|
|
+ userAndProject.add(workHoursStatisticsVO);
|
|
|
}
|
|
|
- userAndProject.add(workHoursStatisticsVO);
|
|
|
}
|
|
|
List<WorkHoursStatisticsVO> userAndProjectD = userAndProject;
|
|
|
|
|
@@ -815,25 +833,32 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
projectWorkTimeVO.setProjectOrPerson(name);
|
|
|
List<BigDecimal> workTime = new ArrayList<>();
|
|
|
boolean hasNonZeroWorkTime = false;
|
|
|
- for (String currentNickName : nickName) {
|
|
|
- boolean foundWorkTime = false;
|
|
|
- for (WorkHoursStatisticsVO workHoursStatisticsVO : userAndProject) {
|
|
|
- String userNickName = workHoursStatisticsVO.getNickName();
|
|
|
- String projectName = workHoursStatisticsVO.getProjectName();
|
|
|
- BigDecimal userProjectWorkTime = workHoursStatisticsVO.getWorkTime();
|
|
|
- if (projectName == name && userNickName == currentNickName) {
|
|
|
- workTime.add(userProjectWorkTime);
|
|
|
- if (userProjectWorkTime.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- hasNonZeroWorkTime = true;
|
|
|
+ if (userAndProject.isEmpty()) {
|
|
|
+ for (String currentNickName : nickName) {
|
|
|
+ workTime.add(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String currentNickName : nickName) {
|
|
|
+ boolean foundWorkTime = false;
|
|
|
+ for (WorkHoursStatisticsVO workHoursStatisticsVO : userAndProject) {
|
|
|
+ String userNickName = workHoursStatisticsVO.getNickName();
|
|
|
+ String projectName = workHoursStatisticsVO.getProjectName();
|
|
|
+ BigDecimal userProjectWorkTime = workHoursStatisticsVO.getWorkTime();
|
|
|
+ if (projectName == name && userNickName == currentNickName) {
|
|
|
+ workTime.add(userProjectWorkTime);
|
|
|
+ if (userProjectWorkTime.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ hasNonZeroWorkTime = true;
|
|
|
+ }
|
|
|
+ foundWorkTime = true;
|
|
|
+ break;
|
|
|
}
|
|
|
- foundWorkTime = true;
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
- if (!foundWorkTime) {
|
|
|
- workTime.add(BigDecimal.ZERO);
|
|
|
+ if (!foundWorkTime) {
|
|
|
+ workTime.add(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ // 过滤0工时
|
|
|
if (filter != 2 || hasNonZeroWorkTime) {
|
|
|
projectWorkTimeVO.setWorkTime(workTime);
|
|
|
projectWorkTime.add(projectWorkTimeVO);
|
|
@@ -849,7 +874,12 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
userWorkTimeVO2.setProjectOrPerson(name);
|
|
|
List<BigDecimal> workTime = new ArrayList<>();
|
|
|
boolean hasNonZeroWorkTime = false;
|
|
|
- for (String currentNickName : pmProjectName) {
|
|
|
+ if (userAndProjectD.isEmpty()) {
|
|
|
+ for (String currentNickName : pmProjectName) {
|
|
|
+ workTime.add(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (String currentNickName : pmProjectName) {
|
|
|
boolean foundWorkTime = false;
|
|
|
for (WorkHoursStatisticsVO workHoursStatisticsVO : userAndProjectD) {
|
|
|
String userNickName = workHoursStatisticsVO.getNickName();
|
|
@@ -868,26 +898,28 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
workTime.add(BigDecimal.ZERO);
|
|
|
}
|
|
|
}
|
|
|
- if (filter != 2 || hasNonZeroWorkTime) {
|
|
|
- userWorkTimeVO2.setWorkTime(workTime);
|
|
|
- userWorkTimeVO.add(userWorkTimeVO2);
|
|
|
- }
|
|
|
}
|
|
|
- returnList.add(userWorkTimeVO);
|
|
|
+ // 过滤0工时
|
|
|
+ if (filter != 2 || hasNonZeroWorkTime) {
|
|
|
+ userWorkTimeVO2.setWorkTime(workTime);
|
|
|
+ userWorkTimeVO.add(userWorkTimeVO2);
|
|
|
+ }
|
|
|
}
|
|
|
- return returnList;
|
|
|
+ returnList.add(userWorkTimeVO);
|
|
|
}
|
|
|
+ return returnList;
|
|
|
+}
|
|
|
|
|
|
- @Override
|
|
|
- public List<WorkTimeExportVO> workHourStatisticExport(Long userId, Integer projectId, String startDate, String endDate) {
|
|
|
- Integer tenantId = SecurityUtils.getTenantId();
|
|
|
- LocalDate start = null;
|
|
|
- LocalDate end = null;
|
|
|
- if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
|
|
|
- start = LocalDate.parse(startDate);
|
|
|
- end = LocalDate.parse(endDate);
|
|
|
- }
|
|
|
- return pmWorkContentMapper.workHourStatisticExport(userId, projectId, start, end, tenantId);
|
|
|
+@Override
|
|
|
+public List<WorkTimeExportVO> workHourStatisticExport(Long userId, Integer projectId, String startDate, String endDate) {
|
|
|
+ Integer tenantId = SecurityUtils.getTenantId();
|
|
|
+ LocalDate start = null;
|
|
|
+ LocalDate end = null;
|
|
|
+ if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
|
|
|
+ start = LocalDate.parse(startDate);
|
|
|
+ end = LocalDate.parse(endDate);
|
|
|
}
|
|
|
+ return pmWorkContentMapper.workHourStatisticExport(userId, projectId, start, end, tenantId);
|
|
|
+}
|
|
|
|
|
|
}
|