|
@@ -103,16 +103,13 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
* @param: []
|
|
|
* @return: java.util.List<java.lang.Integer>
|
|
|
**/
|
|
|
- private List<Integer> receive(LocalDate startDate, LocalDate endDate) {
|
|
|
+ private List<Integer> receive() {
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId)
|
|
|
.eq(PmWorkReport::getTenantId, tenantId)
|
|
|
.apply("FIND_IN_SET(" + userId + ", cc_to) > 0");
|
|
|
- if (startDate != null && endDate != null) {
|
|
|
- reportQuery.between(PmWorkReport::getReportDate, startDate, endDate);
|
|
|
- }
|
|
|
List<PmWorkReport> reportIds = pmWorkReportMapper.selectList(reportQuery);
|
|
|
return reportIds.stream().map(PmWorkReport::getId).collect(Collectors.toList());
|
|
|
}
|
|
@@ -124,16 +121,13 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
* @param: []
|
|
|
* @return: java.util.List<java.lang.Integer>
|
|
|
**/
|
|
|
- private List<Integer> sentOut(LocalDate startDate, LocalDate endDate) {
|
|
|
+ private List<Integer> sentOut() {
|
|
|
Long userid = SecurityUtils.getUserId();
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId)
|
|
|
.eq(PmWorkReport::getTenantId, tenantId)
|
|
|
.eq(PmWorkReport::getSubmitterId, userid);
|
|
|
- if (startDate != null && endDate != null) {
|
|
|
- reportQuery.between(PmWorkReport::getReportDate, startDate, endDate);
|
|
|
- }
|
|
|
List<PmWorkReport> reportIds = pmWorkReportMapper.selectList(reportQuery);
|
|
|
List<Integer> rIds = new ArrayList<>();
|
|
|
for (PmWorkReport report : reportIds) {
|
|
@@ -198,6 +192,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LocalDateTime endDateTime = null;
|
|
|
LocalDate start = null;
|
|
|
LocalDate end = null;
|
|
|
+ List<Integer> reportIds = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
|
|
|
DateTimeFormatter formatter = null;
|
|
|
try {
|
|
@@ -207,51 +202,52 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
start = LocalDate.parse(startDate, formatter);
|
|
|
end = LocalDate.parse(endDate, formatter);
|
|
|
- startDateTime = start.atStartOfDay();
|
|
|
- endDateTime = end.atTime(23, 59, 59);
|
|
|
+ // startDateTime = start.atStartOfDay();
|
|
|
+ // endDateTime = end.atTime(23, 59, 59);
|
|
|
+ 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());
|
|
|
}
|
|
|
|
|
|
List<PmWorkContent> workContentList = new ArrayList<>();
|
|
|
- List<Integer> reportIds = new ArrayList<>();
|
|
|
- if (StringUtils.isBlank(startDate) && StringUtils.isBlank(endDate)) {
|
|
|
- reportIds = reportDateQuery(startDate, endDate);
|
|
|
- }
|
|
|
-
|
|
|
- if (projectAscription != 1 && projectAscription != 2 && projectAscription != 3) {
|
|
|
- throw new BusinessException("查询标识有误");
|
|
|
- }
|
|
|
- List<Integer> receiveList = receive(start, end);
|
|
|
- if (projectAscription == 2 && receiveList.isEmpty()) {
|
|
|
- return workContentList;
|
|
|
- }
|
|
|
- List<Integer> sentOutList = sentOut(start, end);
|
|
|
- if (projectAscription == 3 && sentOutList.isEmpty()) {
|
|
|
- return workContentList;
|
|
|
- }
|
|
|
- List<Integer> headProjects = head();
|
|
|
- if (projectAscription == 1 && headProjects.isEmpty()) {
|
|
|
- return workContentList;
|
|
|
- }
|
|
|
|
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
contentLambdaQuery.select(PmWorkContent::getProjectId, PmWorkContent::getProjectName);
|
|
|
- if (!reportIds.isEmpty()) {
|
|
|
- contentLambdaQuery.in(PmWorkContent::getReportId, reportIds);
|
|
|
+ switch (projectAscription) {
|
|
|
+ case 1:
|
|
|
+ List<Integer> headProjects = head();
|
|
|
+ if (headProjects.isEmpty()) {
|
|
|
+ return workContentList;
|
|
|
+ }
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getProjectId, headProjects);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ List<Integer> receiveList = receive();
|
|
|
+ if (receiveList.isEmpty()) {
|
|
|
+ return workContentList;
|
|
|
+ }
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getReportId, receiveList);
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ List<Integer> sentOutList = sentOut();
|
|
|
+ if (sentOutList.isEmpty()) {
|
|
|
+ return workContentList;
|
|
|
+ }
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getReportId, sentOutList);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ throw new BusinessException("查询标识有误");
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(projectName)) {
|
|
|
contentLambdaQuery.like(PmWorkContent::getProjectName, projectName);
|
|
|
}
|
|
|
- if (projectAscription == 1) {
|
|
|
- contentLambdaQuery.in(PmWorkContent::getProjectId, headProjects)
|
|
|
- .between(PmWorkContent::getCreateTime, startDateTime, endDateTime);
|
|
|
- } else if (projectAscription == 2) {
|
|
|
- contentLambdaQuery.in(PmWorkContent::getReportId, receiveList);
|
|
|
- } else {
|
|
|
- contentLambdaQuery.in(PmWorkContent::getReportId, sentOutList);
|
|
|
+ if (!reportIds.isEmpty()) {
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getReportId, reportIds);
|
|
|
}
|
|
|
contentLambdaQuery.groupBy(PmWorkContent::getProjectId)
|
|
|
.groupBy(PmWorkContent::getProjectName);
|
|
|
- workContentList = this.list(contentLambdaQuery);
|
|
|
+ workContentList = pmWorkContentMapper.selectList(contentLambdaQuery);
|
|
|
|
|
|
return workContentList;
|
|
|
}
|
|
@@ -304,11 +300,11 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
if (projectAscription != 1 && projectAscription != 2 && projectAscription != 3) {
|
|
|
throw new BusinessException("查询标识有误");
|
|
|
}
|
|
|
- List<Integer> receiveList2 = receive(start, end);
|
|
|
+ List<Integer> receiveList2 = receive();
|
|
|
if (projectAscription == 2 && receiveList2.isEmpty()) {
|
|
|
return reportList2;
|
|
|
}
|
|
|
- List<Integer> sentOutList = sentOut(start, end);
|
|
|
+ List<Integer> sentOutList = sentOut();
|
|
|
if (projectAscription == 3 && sentOutList.isEmpty()) {
|
|
|
return reportList2;
|
|
|
}
|
|
@@ -423,8 +419,10 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
usersQuery.select(SysUser::getUserId, SysUser::getNickName, SysUser::getUserName, SysUser::getPhonenumber, SysUser::getAvatar,
|
|
|
SysUser::getSex, SysUser::getDeptId)
|
|
|
.eq(SysUser::getTenantId, SecurityUtils.getTenantId())
|
|
|
- .eq(SysUser::getDelFlag, 0)
|
|
|
- .in(SysUser::getUserId, userIds);
|
|
|
+ .eq(SysUser::getDelFlag, 0);
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
+ usersQuery.in(SysUser::getUserId, userIds);
|
|
|
+ }
|
|
|
return sysUserMapper.selectList(usersQuery);
|
|
|
}
|
|
|
|
|
@@ -450,6 +448,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
LocalDateTime endDateTime = null;
|
|
|
LocalDate start = null;
|
|
|
LocalDate end = null;
|
|
|
+ List<Integer> reportIds = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
|
|
|
DateTimeFormatter formatter = null;
|
|
|
try {
|
|
@@ -459,94 +458,95 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
start = LocalDate.parse(startDate, formatter);
|
|
|
end = LocalDate.parse(endDate, formatter);
|
|
|
- startDateTime = start.atStartOfDay();
|
|
|
- endDateTime = end.atTime(23, 59, 59);
|
|
|
+ // startDateTime = start.atStartOfDay();
|
|
|
+ // endDateTime = end.atTime(23, 59, 59);
|
|
|
+ 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 (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()));
|
|
|
}
|
|
|
|
|
|
CommonPage<PmWorkReport> returnPage = new CommonPage<>(new ArrayList<>(), 0, pageSize, pageNum);
|
|
|
Integer tenantId = SecurityUtils.getTenantId();
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
- Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
|
|
-
|
|
|
- if (projectAscription != 1 && projectAscription != 2 && projectAscription != 3) {
|
|
|
- throw new BusinessException("查询标识有误");
|
|
|
- }
|
|
|
- List<Integer> headProjects = head();
|
|
|
- if (projectAscription == 1 && headProjects.isEmpty()) {
|
|
|
- return returnPage;
|
|
|
- }
|
|
|
- List<Integer> receiveList2 = receive(start, end);
|
|
|
- if (projectAscription == 2 && receiveList2.isEmpty()) {
|
|
|
- return returnPage;
|
|
|
- }
|
|
|
- List<Integer> sentOutList = sentOut(start, end);
|
|
|
- if (projectAscription == 3 && sentOutList.isEmpty()) {
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ List<Integer> receiveList = receive();
|
|
|
+ if (receiveList.isEmpty()) {
|
|
|
return returnPage;
|
|
|
}
|
|
|
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
LambdaQueryWrapper<PmWorkContent> contentLambdaQuery = Wrappers.lambdaQuery();
|
|
|
contentLambdaQuery.select(PmWorkContent::getReportId, PmWorkContent::getWorkContent, PmWorkContent::getWorkTime, PmWorkContent::getProjectName);
|
|
|
- if (reportId != null && reportId != 0) {
|
|
|
+ if (reportId != null && reportId > 0) {
|
|
|
contentLambdaQuery.eq(PmWorkContent::getReportId, reportId);
|
|
|
} else {
|
|
|
- contentLambdaQuery.eq(PmWorkContent::getTenantId, tenantId).eq(PmWorkContent::getDeptId, deptId);
|
|
|
-
|
|
|
- if (projectId != null && projectId != 0) {
|
|
|
- contentLambdaQuery.eq(PmWorkContent::getProjectId, projectId);
|
|
|
- }
|
|
|
-
|
|
|
- if (startDateTime != null) {
|
|
|
- contentLambdaQuery.between(PmWorkContent::getCreateTime, startDateTime, endDateTime);
|
|
|
- }
|
|
|
-
|
|
|
switch (projectAscription) {
|
|
|
case 1:
|
|
|
- contentLambdaQuery.in(PmWorkContent::getReportId, headProjects);
|
|
|
+ List<Integer> headProjects = head();
|
|
|
+ if (headProjects.isEmpty()) {
|
|
|
+ return returnPage;
|
|
|
+ }
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getProjectId, headProjects);
|
|
|
break;
|
|
|
case 2:
|
|
|
- contentLambdaQuery.in(PmWorkContent::getReportId, receiveList2);
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getReportId, receiveList);
|
|
|
break;
|
|
|
case 3:
|
|
|
+ List<Integer> sentOutList = sentOut();
|
|
|
+ if (sentOutList.isEmpty()) {
|
|
|
+ return returnPage;
|
|
|
+ }
|
|
|
contentLambdaQuery.in(PmWorkContent::getReportId, sentOutList);
|
|
|
break;
|
|
|
+ default:
|
|
|
+ throw new BusinessException("查询标识有误!");
|
|
|
+ }
|
|
|
+ if (!reportIds.isEmpty()) {
|
|
|
+ contentLambdaQuery.in(PmWorkContent::getReportId, reportIds);
|
|
|
}
|
|
|
}
|
|
|
List<PmWorkContent> pmWorkContentList = pmWorkContentMapper.selectList(contentLambdaQuery);
|
|
|
-
|
|
|
- if (receiveList2.isEmpty()) {
|
|
|
+ if (pmWorkContentList.isEmpty()) {
|
|
|
+ if (reportId != null && reportId > 0) {
|
|
|
+ throw new BusinessException("该报告已被删除!");
|
|
|
+ }
|
|
|
return returnPage;
|
|
|
}
|
|
|
+ List<Integer> reportIds2 = pmWorkContentList.stream().distinct().map(PmWorkContent::getReportId).collect(Collectors.toList());
|
|
|
|
|
|
LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
|
|
|
reportQuery.select(PmWorkReport::getId, PmWorkReport::getCoordinateWork, PmWorkReport::getTomorrowPlan, PmWorkReport::getCcTo, PmWorkReport::getSubmitterId,
|
|
|
- PmWorkReport::getSubmitDate, PmWorkReport::getReportDate, PmWorkReport::getCreateBy);
|
|
|
+ PmWorkReport::getSubmitDate, PmWorkReport::getReportDate, PmWorkReport::getCreateBy)
|
|
|
+ .eq(PmWorkReport::getReportStatus, 1);
|
|
|
if (reportId != null && reportId != 0) {
|
|
|
reportQuery.eq(PmWorkReport::getId, reportId);
|
|
|
} else {
|
|
|
- reportQuery.in(PmWorkReport::getId, receiveList2)
|
|
|
+ reportQuery.in(PmWorkReport::getId, reportIds2)
|
|
|
.orderByDesc(PmWorkReport::getCreateTime);
|
|
|
}
|
|
|
- reportQuery.eq(PmWorkReport::getReportStatus, 1);
|
|
|
IPage<PmWorkReport> reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery);
|
|
|
- if (reportPage.getRecords() == null || reportPage.getRecords().isEmpty()) {
|
|
|
- return returnPage;
|
|
|
- }
|
|
|
List<PmWorkReport> reportList = reportPage.getRecords();
|
|
|
|
|
|
-
|
|
|
+ // 查询已读状态
|
|
|
LambdaQueryWrapper<PmReceive> statusQuery = Wrappers.lambdaQuery();
|
|
|
statusQuery.select(PmReceive::getReportId, PmReceive::getReadFlag)
|
|
|
.eq(PmReceive::getReceiverId, userId);
|
|
|
if (reportId != null && reportId != 0) {
|
|
|
statusQuery.eq(PmReceive::getReportId, reportId);
|
|
|
- } else if (!receiveList2.isEmpty()) {
|
|
|
- statusQuery.in(PmReceive::getReportId, receiveList2);
|
|
|
+ } else if (!receiveList.isEmpty()) {
|
|
|
+ statusQuery.in(PmReceive::getReportId, receiveList);
|
|
|
}
|
|
|
- List<PmReceive> receiveList = pmReceiveMapper.selectList(statusQuery);
|
|
|
+ List<PmReceive> receiveList2 = pmReceiveMapper.selectList(statusQuery);
|
|
|
|
|
|
Map<Integer, Integer> reportReadFlags = new HashMap<>();
|
|
|
- for (PmReceive pmReceive : receiveList) {
|
|
|
+ for (PmReceive pmReceive : receiveList2) {
|
|
|
Integer reportId2 = pmReceive.getReportId();
|
|
|
reportReadFlags.put(reportId2, pmReceive.getReadFlag());
|
|
|
}
|
|
@@ -571,18 +571,22 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
|
|
|
}
|
|
|
|
|
|
|
|
|
- // 已读未读查询
|
|
|
- List<PmReceive> receives = receives(receiveList2);
|
|
|
+ // 已读未读数量查询
|
|
|
+ List<PmReceive> receives = receives(receiveList);
|
|
|
List<Long> uId = new ArrayList<>();
|
|
|
for (PmReceive pmReceive : receives) {
|
|
|
Long receiverId = pmReceive.getReceiverId();
|
|
|
uId.add(receiverId);
|
|
|
}
|
|
|
|
|
|
- List<Long> userIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ Set<Long> userIdSet = new HashSet<>();
|
|
|
for (PmWorkReport report : reportList) {
|
|
|
- userIdList.add(report.getSubmitterId());
|
|
|
+ Long submitterId = report.getSubmitterId();
|
|
|
+ userIdSet.add(submitterId);
|
|
|
}
|
|
|
+ List<Long> userIdList = new ArrayList<>(userIdSet);
|
|
|
+
|
|
|
List<SysUser> sysUsers = nickNames(userIdList);
|
|
|
|
|
|
Map<Integer, List<PmReceive>> reportReceivesMap = receives.stream()
|