Browse Source

Merge branch 'fu-normal-push' of uskycloud/usky-modules into master

gez 1 week ago
parent
commit
477eaaf953

+ 2 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/mapper/PmWorkContentMapper.java

@@ -27,7 +27,8 @@ public interface PmWorkContentMapper extends CrudMapper<PmWorkContent> {
 
     List<PmProjectWorkTimeVo> workTimeCount(@Param("startTime") LocalDateTime startTime,
                                             @Param("endTime") LocalDateTime endTime,
-                                            @Param("userId") Long userId);
+                                            @Param("userId") Long userId,
+                                            @Param("tenantId") Integer tenantId);
 
 /*    List<WorkHoursStatisticsVO> workHoursStatistics(@Param("startTime") LocalDate startTime,
                                                     @Param("endTime") LocalDate endTime,

+ 11 - 26
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmProjectServiceImpl.java

@@ -75,7 +75,7 @@ public class PmProjectServiceImpl extends AbstractCrudService<PmProjectMapper, P
         String projectName = project.getProjectName();
         if (StringUtils.isBlank(projectName)) {
             throw new BusinessException("项目名称不能为空!");
-        }else if (projectName.length() > 50) {
+        } else if (projectName.length() > 50) {
             throw new BusinessException("项目名称长度不能超过50个字符!");
         }
 
@@ -88,7 +88,7 @@ public class PmProjectServiceImpl extends AbstractCrudService<PmProjectMapper, P
         Integer projectType = project.getProjectType();
         if (projectType == null) {
             throw new BusinessException("项目类型不能为空且");
-        }else if (projectType < 1 || projectType > 6) {
+        } else if (projectType < 1 || projectType > 6) {
             throw new BusinessException("项目类型传参有误!");
         }
 
@@ -96,7 +96,7 @@ public class PmProjectServiceImpl extends AbstractCrudService<PmProjectMapper, P
         Integer projectStatus = project.getProjectStatus();
         if (projectStatus == null) {
             throw new BusinessException("项目状态不能为空且!");
-        }else if (projectStatus < 1 || projectStatus > 5) {
+        } else if (projectStatus < 1 || projectStatus > 5) {
             throw new BusinessException("项目状态传参有误!");
         }
 
@@ -249,43 +249,26 @@ public class PmProjectServiceImpl extends AbstractCrudService<PmProjectMapper, P
 
         LambdaQueryWrapper<PmProject> lambdaQuery = Wrappers.lambdaQuery();
         lambdaQuery.eq(PmProject::getTenantId, tenantId)
-                .eq(PmProject::getDelFlag, 0)
-                .eq(visibleRange != null, PmProject::getVisibleRange, visibleRange);
+                .eq(PmProject::getDelFlag, 0);
 
         if (projectId != null && projectId != 0) {
             lambdaQuery.eq(PmProject::getId, projectId);
-            page = this.page(page, lambdaQuery);
-            return new CommonPage<>(page.getRecords(), page.getTotal(), pageSize, pageNum);
         }
 
         switch (projectAscription) {
             case 0:
-                if (StringUtils.isNotBlank(projectName) || projectType != null || projectStatus != null) {
-                    lambdaQuery.eq(PmProject::getDelFlag, 0)
-                            .like(StringUtils.isNotBlank(projectName), PmProject::getProjectName, projectName)
-                            .eq(projectType != null, PmProject::getProjectType, projectType)
-                            .eq(projectStatus != null, PmProject::getProjectStatus, projectStatus)
+                if (visibleRange == null) {
+                    lambdaQuery.and(wrapper -> wrapper
                             .and(qw -> qw
                                     .eq(PmProject::getProjectHead, userId)
                                     .or()
                                     .apply("FIND_IN_SET('" + userId + "', project_member) > 0")
                                     .or()
-                                    .eq(PmProject::getCreateBy, username));
-                }
-                if (visibleRange == null) {
-                    lambdaQuery.eq(PmProject::getDelFlag, 0)
-                            .and(wrapper -> wrapper
-                                    .eq(PmProject::getVisibleRange, 2)
-                                    .and(qw -> qw
-                                            .eq(PmProject::getProjectHead, userId)
-                                            .or()
-                                            .apply("FIND_IN_SET('" + userId + "', project_member) > 0")
-                                            .or()
-                                            .eq(PmProject::getCreateBy, username))
+                                    .eq(PmProject::getCreateBy, username)
                             )
                             .or()
                             .eq(PmProject::getVisibleRange, 1)
-                            .eq(PmProject::getDelFlag, 0);
+                    );
                 } else if (visibleRange == 2) {
                     lambdaQuery.and(wrapper -> wrapper
                             .eq(PmProject::getProjectHead, userId)
@@ -314,7 +297,9 @@ public class PmProjectServiceImpl extends AbstractCrudService<PmProjectMapper, P
             default:
                 throw new BusinessException("查询项目列表参数错误");
         }
-        lambdaQuery.orderByDesc(PmProject::getCreateTime);
+
+        lambdaQuery.eq(visibleRange != null, PmProject::getVisibleRange, visibleRange)
+                .orderByDesc(PmProject::getCreateTime);
         List<PmProject> pmProjects = pmProjectMapper.selectList(lambdaQuery);
         if (pmProjects.isEmpty()) {
             return new CommonPage<>(pmProjects, 0, pageSize, pageNum);

+ 10 - 4
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkReportServiceImpl.java

@@ -95,6 +95,9 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
      */
     @Override
     public List<Map<String, List<PmWorkReport>>> weekWork(String startDate, String endDate, Integer reportId) {
+        Long userId = SecurityUtils.getUserId();
+        Integer tenantId = SecurityUtils.getTenantId();
+
         List<Map<String, List<PmWorkReport>>> returnList = new ArrayList<>();
         List<PmWorkReport> report = new ArrayList<>();
         Map<String, List<PmWorkReport>> weekData = new HashMap<>();
@@ -114,9 +117,10 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
             dates.add(tempDate);
             tempDate = tempDate.plusDays(1);
         }
+
         // 返回最新的一条数据给前端填充
         LambdaQueryWrapper<PmWorkReport> wrapper2 = Wrappers.lambdaQuery();
-        wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+        wrapper2.eq(PmWorkReport::getSubmitterId, userId)
                 .orderByDesc(PmWorkReport::getSubmitDate)
                 .last("LIMIT 1");
         report = baseMapper.selectList(wrapper2);
@@ -127,9 +131,11 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
             List<PmWorkContent> contents1 = pmWorkContentMapper.selectList(wrapper);
             report.get(0).setWorkContents(contents1);
         }
+
         // 固定返回七条数据,没有内容也要设置时间给前端渲染
         LambdaQueryWrapper<PmWorkReport> queryWrapperR = Wrappers.lambdaQuery();
-        queryWrapperR.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+        queryWrapperR.eq(PmWorkReport::getTenantId, tenantId)
+    .eq(PmWorkReport::getSubmitterId, userId)
                 .between(reportId == 0, PmWorkReport::getReportDate, startDate1, endDate1)
                 .eq(reportId != 0, PmWorkReport::getId, reportId)
                 .orderByAsc(PmWorkReport::getReportDate);
@@ -174,7 +180,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
         if (reports.size() == 7 || reportId != 0) {
             weekData.put("weekData", reports);
             LambdaQueryWrapper<PmWorkReport> wrapper1 = Wrappers.lambdaQuery();
-            wrapper1.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+            wrapper1.eq(PmWorkReport::getSubmitterId, userId)
                     .orderByDesc(PmWorkReport::getReportDate)
                     .last("LIMIT 1");
             report = this.list(wrapper1);
@@ -499,7 +505,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
         LocalDateTime endTime = stringLocalDateTimeMap.get("end");
         BigDecimal totalWorkTime = BigDecimal.ZERO;
 
-        List<PmProjectWorkTimeVo> week = pmWorkContentMapper.workTimeCount(startTime, endTime, SecurityUtils.getUserId());
+        List<PmProjectWorkTimeVo> week = pmWorkContentMapper.workTimeCount(startTime, endTime, SecurityUtils.getUserId(), SecurityUtils.getTenantId());
         if (week.isEmpty()) {
             projectTotalWorkTimeVo.setTotalWorkTime(totalWorkTime);
             projectTotalWorkTimeVo.setProjectWorkTime(week);

+ 2 - 1
service-iot/service-iot-biz/src/main/resources/mapper/iot/PmWorkContentMapper.xml

@@ -21,9 +21,10 @@
     <select id="workTimeCount" resultType="com.usky.iot.service.vo.PmProjectWorkTimeVo">
         SELECT pc.project_name, SUM(pc.work_time) as workTime
         FROM pm_work_content pc
-            JOIN pm_work_report pr ON pc.report_id = pr.id
+                 JOIN pm_work_report pr ON pc.report_id = pr.id
         WHERE pr.submitter_id = #{userId}
           AND pr.report_date BETWEEN #{startTime} AND #{endTime}
+          AND pr.tenant_id = #{tenantId}
         GROUP BY pc.project_name
     </select>