Browse Source

修复报告记录查询某用户所有日报未加抄送人判断

fuyuchuan 1 week ago
parent
commit
8f4f1a002a

+ 21 - 11
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkContentServiceImpl.java

@@ -465,6 +465,7 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             }
         }
         Integer tenantId = SecurityUtils.getTenantId();
+        Long nowUserId = SecurityUtils.getUserId();
         LocalDate start = null;
         LocalDate end = null;
         List<Integer> reportIds = new ArrayList<>();
@@ -475,6 +476,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         Set<Integer> reportIdsByProject = new HashSet<>();
         Set<Integer> reportIdsSet = new HashSet<>();
 
+        LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
+
         if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)) {
             DateTimeFormatter formatter = null;
             try {
@@ -486,7 +489,6 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
             end = LocalDate.parse(endDate, formatter);
             startDateTime = start.atStartOfDay();
             endDateTime = end.atTime(23, 59, 59);
-            LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
             reportQuery.select(PmWorkReport::getId).eq(PmWorkReport::getReportStatus, 1).between(PmWorkReport::getSubmitDate, startDateTime, endDateTime);
             reportIdsByDate = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toSet());
         }
@@ -498,8 +500,8 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         }
 
         if (userId != null) {
-            LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
-            reportQuery.eq(PmWorkReport::getSubmitterId, userId);
+            reportQuery.eq(PmWorkReport::getSubmitterId, userId)
+                    .and(wrappers -> wrappers.apply("FIND_IN_SET(" + nowUserId + ", cc_to) > 0"));
             reportIdsByUser = pmWorkReportMapper.selectList(reportQuery).stream().map(PmWorkReport::getId).collect(Collectors.toSet());
             if (reportIdsByProject.isEmpty() && reportIdsByUser.isEmpty()) {
                 return returnPage;
@@ -538,8 +540,16 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
         } else if (!reportIdsByDate.isEmpty()) {
             reportIdsSet.addAll(reportIdsByDate);
         }
+
         reportIds = new ArrayList<>(reportIdsSet);
 
+        if (projectAscription == 1) {
+            LambdaQueryWrapper<PmWorkReport> headerQuery = Wrappers.lambdaQuery();
+            headerQuery.in(!reportIds.isEmpty(), PmWorkReport::getId, reportIds)
+                    .and(wrappers -> wrappers.apply("FIND_IN_SET(" + nowUserId + ", cc_to) > 0"));
+            reportIds = pmWorkReportMapper.selectList(headerQuery).stream().map(PmWorkReport::getId).collect(Collectors.toList());
+        }
+
         List<PmWorkContent> pmWorkContentList = new ArrayList<>();
         Long userId2 = SecurityUtils.getUserId();
         List<Long> userIds = new ArrayList<>();
@@ -588,22 +598,22 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
 
         List<Integer> reportIds2 = pmWorkContentList.stream().distinct().map(PmWorkContent::getReportId).collect(Collectors.toList());
 
-        LambdaQueryWrapper<PmWorkReport> reportQuery = Wrappers.lambdaQuery();
-        reportQuery.eq(PmWorkReport::getTenantId, tenantId).eq(PmWorkReport::getReportStatus, 1);
+        LambdaQueryWrapper<PmWorkReport> reportQuery1 = Wrappers.lambdaQuery();
+        reportQuery1.eq(PmWorkReport::getTenantId, tenantId).eq(PmWorkReport::getReportStatus, 1);
         if (reportId != null && reportId != 0) {
-            reportQuery.eq(PmWorkReport::getId, reportId);
+            reportQuery1.eq(PmWorkReport::getId, reportId);
         } else {
-            reportQuery.in(PmWorkReport::getId, reportIds2);
+            reportQuery1.in(PmWorkReport::getId, reportIds2);
             // 判断上下滑动以及数量
             if (upOrDown != null && slideSum != null && submitDateTime != null) {
                 if (slideSum > 0) {
                     // 向下滑动
                     if (upOrDown == 0) {
-                        reportQuery.lt(PmWorkReport::getSubmitDate, submitDateTime).orderByDesc(PmWorkReport::getSubmitDate);
+                        reportQuery1.lt(PmWorkReport::getSubmitDate, submitDateTime).orderByDesc(PmWorkReport::getSubmitDate);
                     }
                     // 向上滑动
                     else if (upOrDown == 1) {
-                        reportQuery.gt(PmWorkReport::getSubmitDate, submitDateTime).orderByAsc(PmWorkReport::getSubmitDate);
+                        reportQuery1.gt(PmWorkReport::getSubmitDate, submitDateTime).orderByAsc(PmWorkReport::getSubmitDate);
                     } else {
                         throw new BusinessException("上下滑动参数异常");
                     }
@@ -614,11 +624,11 @@ public class PmWorkContentServiceImpl extends AbstractCrudService<PmWorkContentM
                     throw new BusinessException("滑动数量参数必须是大于0正整数");
                 }
             } else {
-                reportQuery.orderByDesc(PmWorkReport::getSubmitDate);
+                reportQuery1.orderByDesc(PmWorkReport::getSubmitDate);
             }
         }
 
-        reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery);
+        reportPage = pmWorkReportMapper.selectPage(new Page<>(pageNum, pageSize), reportQuery1);
         reportList = reportPage.getRecords();
 
         // 查询已读状态