소스 검색

Merge branch 'fu-dev' of uskycloud/usky-modules into server-165

fuyuchuan 11 달 전
부모
커밋
4088931dda

+ 1 - 1
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/PmWorkReportController.java

@@ -37,7 +37,7 @@ public class PmWorkReportController {
      * @return
      */
     @GetMapping("/week")
-    public ApiResult<List<PmWorkReport>> weekWork(@RequestParam(required = false) String startDate,
+    public ApiResult<List<Map<String, List<PmWorkReport>>>> weekWork(@RequestParam(required = false) String startDate,
                                                   @RequestParam(required = false) String endDate,
                                                   @RequestParam(required = false, defaultValue = "0") Integer id) {
 

+ 2 - 2
service-iot/service-iot-biz/src/main/java/com/usky/iot/domain/PmWorkReport.java

@@ -3,13 +3,13 @@ package com.usky.iot.domain;
 import java.math.BigDecimal;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.io.Serializable;
 import java.util.List;
-import java.util.Map;
 
 import lombok.*;
 import org.springframework.data.annotation.Transient;
@@ -102,7 +102,7 @@ public class PmWorkReport implements Serializable {
     /**
      * 工作报告对应内容
      */
-    @Transient
+    @TableField(exist = false)
     private List<PmWorkContent> workContents;
 
 

+ 1 - 5
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/PmWorkReportService.java

@@ -1,12 +1,8 @@
 package com.usky.iot.service;
 
-import com.usky.iot.domain.PmWorkContent;
 import com.usky.iot.domain.PmWorkReport;
 import com.usky.common.mybatis.core.CrudService;
-import com.usky.iot.service.vo.PmProjectWorkTimeVo;
 
-import java.time.LocalDate;
-import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 
@@ -27,7 +23,7 @@ public interface PmWorkReportService extends CrudService<PmWorkReport> {
      * @param reportId 报告id
      * @return
      */
-    List<PmWorkReport> weekWork(String startDate, String endDate, Integer reportId);
+    List<Map<String, List<PmWorkReport>>> weekWork(String startDate, String endDate, Integer reportId);
 
     /**
      * 新增、编辑工作报告

+ 43 - 8
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/impl/PmWorkReportServiceImpl.java

@@ -7,14 +7,12 @@ import com.usky.common.security.utils.SecurityUtils;
 import com.usky.iot.domain.PmProject;
 import com.usky.iot.domain.PmWorkContent;
 import com.usky.iot.domain.PmWorkReport;
-import com.usky.iot.mapper.PmProjectMapper;
 import com.usky.iot.mapper.PmWorkContentMapper;
 import com.usky.iot.mapper.PmWorkReportMapper;
 import com.usky.iot.service.PmProjectService;
 import com.usky.iot.service.PmWorkContentService;
 import com.usky.iot.service.PmWorkReportService;
 import com.usky.common.mybatis.core.AbstractCrudService;
-import com.usky.iot.service.vo.PmProjectTotalWorkTimeVo;
 import com.usky.iot.service.vo.PmProjectWorkTimeVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -24,7 +22,6 @@ import java.math.RoundingMode;
 import java.time.DayOfWeek;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.LocalTime;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 
@@ -61,7 +58,10 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
      * @return
      */
     @Override
-    public List<PmWorkReport> weekWork(String startDate, String endDate, Integer reportId) {
+    public List<Map<String, List<PmWorkReport>>> weekWork(String startDate, String endDate, Integer reportId) {
+        List<Map<String, List<PmWorkReport>>> returnList2 = new ArrayList<>();
+        Map<String, List<PmWorkReport>> weekData = new HashMap<>();
+        Map<String, List<PmWorkReport>> newData = new HashMap<>();
         LocalDate startDate1 = null;
         LocalDate endDate1 = null;
         if (startDate == null && endDate == null) {
@@ -84,7 +84,7 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 .between(PmWorkReport::getReportDate, startDate1, endDate1)
                 .orderByAsc(PmWorkReport::getReportDate)
                 .apply(reportId != 0, "id = " + reportId);
-        List<PmWorkReport> reports = this.list(queryWrapperR);
+        List<PmWorkReport> reports = baseMapper.selectList(queryWrapperR);
         if (reports.isEmpty()) {
             List<PmWorkReport> reports1 = new ArrayList<>();
             for (int f = 0; f < dates.size(); f++) {
@@ -94,7 +94,12 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 report1.setWorkContents(content);
                 reports1.add(report1);
             }
-            return reports1;
+            weekData.put("weekData", reports1);
+            List<PmWorkReport> report = new ArrayList<>();
+            newData.put("newData", report);
+            returnList2.add(weekData);
+            returnList2.add(newData);
+            return returnList2;
         }
         List<Integer> ids = new ArrayList<>();
         for (PmWorkReport pwr : reports) {
@@ -118,7 +123,21 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
             reports.get(i).setWorkContents(contentList);
         }
         if (reports.size() == 7 || reportId != 0) {
-            return reports;
+            weekData.put("weekData", reports);
+            returnList2.add(weekData);
+            LambdaQueryWrapper<PmWorkReport> wrapper1 = Wrappers.lambdaQuery();
+            wrapper1.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+                    .orderByDesc(PmWorkReport::getReportDate)
+                    .last("LIMIT 1");
+            List<PmWorkReport> report = this.list(wrapper1);
+            Integer rId = report.get(0).getId();
+            LambdaQueryWrapper<PmWorkContent> wrapperC = Wrappers.lambdaQuery();
+            wrapperC.eq(PmWorkContent::getProjectId, rId);
+            List<PmWorkContent> pmWorkContents = pmWorkContentMapper.selectList(wrapperC);
+            report.get(0).setWorkContents(pmWorkContents);
+            newData.put("newData", report);
+            returnList2.add(newData);
+            return returnList2;
         }
         List<PmWorkReport> reportList = new ArrayList<>();
         for (int d = 0; d < dates.size(); d++) {
@@ -138,7 +157,23 @@ public class PmWorkReportServiceImpl extends AbstractCrudService<PmWorkReportMap
                 reportList.add(newReport);
             }
         }
-        return reportList;
+        //返回最新的一条数据给前端填充
+        LambdaQueryWrapper<PmWorkReport> wrapper2 = Wrappers.lambdaQuery();
+        wrapper2.eq(PmWorkReport::getSubmitterId, SecurityUtils.getUserId())
+                .orderByDesc(PmWorkReport::getReportDate)
+                .last("LIMIT 1");
+        List<PmWorkReport> report = baseMapper.selectList(wrapper2);
+        Integer rId = report.get(0).getId();
+        LambdaQueryWrapper<PmWorkContent> wrapperC = Wrappers.lambdaQuery();
+        wrapperC.eq(PmWorkContent::getProjectId, rId);
+        List<PmWorkContent> pmWorkContents = pmWorkContentMapper.selectList(wrapperC);
+        report.get(0).setWorkContents(pmWorkContents);
+        newData.put("newData", report);
+        weekData.put("weekData", reportList);
+        List<Map<String, List<PmWorkReport>>> returnList = new ArrayList<>();
+        returnList.add(newData);
+        returnList.add(weekData);
+        return returnList;
     }
 
     /**