Procházet zdrojové kódy

复制上一期周报内容返回给前端

王燏镕 před 6 měsíci
rodič
revize
9e60caaf1d

+ 0 - 4
pms-service/pom.xml

@@ -183,10 +183,6 @@
             <artifactId>freemarker</artifactId>
             <version>2.3.30</version>
         </dependency>
-        <dependency>
-            <groupId>com.fasterxml.jackson.core</groupId>
-            <artifactId>jackson-databind</artifactId>
-        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 65 - 24
pms-service/src/main/java/com/tofly/pms/supervise/controller/ReportContentController.java

@@ -98,42 +98,42 @@ public class ReportContentController {
     @PostMapping("/pageProjectReport")
     public Page<ProjectReportContent> pageContent(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.PROJECT_REPORT;
-        return contentService.pageQuery(query,reportType);
+        return contentService.pageQuery(query, reportType);
     }
 
     @ApiOperation("分页查询实施周报内容")
     @PostMapping("/pageCarryOut")
     public Page<ProjectReportCarryOut> pageCarryOut(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.CARRY_OUT;
-        return carryOutService.pageQuery(query,reportType);
+        return carryOutService.pageQuery(query, reportType);
     }
 
     @ApiOperation("分页查询测绘周报内容")
     @PostMapping("/pageMapping")
     public Page<ProjectReportMapping> pageMapping(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.MAPPING;
-        return mappingService.pageQuery(query,reportType);
+        return mappingService.pageQuery(query, reportType);
     }
 
     @ApiOperation("分页查询研发周报内容")
     @PostMapping("/pageDevelopment")
     public Page<ProjectReportDevelopment> pageDevelopment(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.DEVELOPMENT;
-        return developmentService.pageQuery(query,reportType);
+        return developmentService.pageQuery(query, reportType);
     }
 
     @ApiOperation("分页查询产品周报内容")
     @PostMapping("/pageProduct")
     public Page<ProjectReportProduct> pageProduct(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.PRODUCT;
-        return productService.pageQuery(query,reportType);
+        return productService.pageQuery(query, reportType);
     }
 
     @ApiOperation("分页查询测试周报内容")
     @PostMapping("/pageTest")
     public Page<ProjectReportTest> pageTest(@RequestBody ReportContentQuery query) {
         ProjectReportType reportType = ProjectReportType.TEST;
-        return testService.pageQuery(query,reportType);
+        return testService.pageQuery(query, reportType);
     }
 
     /**
@@ -261,32 +261,37 @@ public class ReportContentController {
      **/
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportProjectReport")
-    public ProjectReportContent getReportProjectReport(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportContent getReportProjectReport(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return contentService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
+
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportDevelopment")
-    public ProjectReportDevelopment getReportDevelopment(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportDevelopment getReportDevelopment(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return developmentService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
+
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportProduct")
-    public ProjectReportProduct getReportProduct(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportProduct getReportProduct(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return productService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
+
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportTest")
-    public ProjectReportTest getReportTest(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportTest getReportTest(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return testService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
+
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportCarryOut")
-    public ProjectReportCarryOut getReportCarryOut(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportCarryOut getReportCarryOut(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return carryOutService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
+
     @ApiOperation("根据项目id和周报id查询填报的详情")
     @GetMapping("/getReportMapping")
-    public ProjectReportMapping getReportMapping(@RequestParam("reportId") String reportId,@RequestParam("projectId") Integer projectId) {
+    public ProjectReportMapping getReportMapping(@RequestParam("reportId") String reportId, @RequestParam("projectId") Integer projectId) {
         return mappingService.getEntityByReportIdAndProjectId(reportId, projectId);
     }
 
@@ -303,9 +308,10 @@ public class ReportContentController {
     })
     public ProjectReportContent getNextReportProjectReport(@RequestParam("reportId") String reportId,
                                                            @RequestParam("projectId") Integer projectId,
-                                                           @RequestParam("next")String next) {
-        return contentService.getEntityByNext(reportId, projectId,next);
+                                                           @RequestParam("next") String next) {
+        return contentService.getEntityByNext(reportId, projectId, next);
     }
+
     @ApiOperation("根据项目id和周报id查询next期的详情")
     @GetMapping("/getNextReportDevelopment")
     @ApiImplicitParams({
@@ -315,9 +321,10 @@ public class ReportContentController {
     })
     public ProjectReportDevelopment getNextReportDevelopment(@RequestParam("reportId") String reportId,
                                                              @RequestParam("projectId") Integer projectId,
-                                                             @RequestParam("next")String next) {
-        return developmentService.getEntityByNext(reportId, projectId,next);
+                                                             @RequestParam("next") String next) {
+        return developmentService.getEntityByNext(reportId, projectId, next);
     }
+
     @ApiOperation("根据项目id和周报id查询next期的详情")
     @GetMapping("/getNextReportProduct")
     @ApiImplicitParams({
@@ -327,9 +334,10 @@ public class ReportContentController {
     })
     public ProjectReportProduct getNextReportProduct(@RequestParam("reportId") String reportId,
                                                      @RequestParam("projectId") Integer projectId,
-                                                     @RequestParam("next")String next) {
-        return productService.getEntityByNext(reportId, projectId,next);
+                                                     @RequestParam("next") String next) {
+        return productService.getEntityByNext(reportId, projectId, next);
     }
+
     @ApiOperation("根据项目id和周报id查询next期的详情")
     @GetMapping("/getNextReportTest")
     @ApiImplicitParams({
@@ -339,9 +347,10 @@ public class ReportContentController {
     })
     public ProjectReportTest getNextReportTest(@RequestParam("reportId") String reportId,
                                                @RequestParam("projectId") Integer projectId,
-                                               @RequestParam("next")String next) {
-        return testService.getEntityByNext(reportId, projectId,next);
+                                               @RequestParam("next") String next) {
+        return testService.getEntityByNext(reportId, projectId, next);
     }
+
     @ApiOperation("根据项目id和周报id查询next期的详情")
     @GetMapping("/getNextReportCarryOut")
     @ApiImplicitParams({
@@ -351,9 +360,10 @@ public class ReportContentController {
     })
     public ProjectReportCarryOut getNextReportCarryOut(@RequestParam("reportId") String reportId,
                                                        @RequestParam("projectId") Integer projectId,
-                                                       @RequestParam("next")String next) {
-        return carryOutService.getEntityByNext(reportId, projectId,next);
+                                                       @RequestParam("next") String next) {
+        return carryOutService.getEntityByNext(reportId, projectId, next);
     }
+
     @ApiOperation("根据项目id和周报id查询next期的详情")
     @GetMapping("/getNextReportMapping")
     @ApiImplicitParams({
@@ -363,7 +373,38 @@ public class ReportContentController {
     })
     public ProjectReportMapping getNextReportMapping(@RequestParam("reportId") String reportId,
                                                      @RequestParam("projectId") Integer projectId,
-                                                     @RequestParam("next")String next) {
-        return mappingService.getEntityByNext(reportId, projectId,next);
+                                                     @RequestParam("next") String next) {
+        return mappingService.getEntityByNext(reportId, projectId, next);
+    }
+
+    /**
+     * ================================根据项目id和周报id复制上一期项目周报内容================================================
+     **/
+    @ApiOperation("根据项目id和周报id复制上一期项目周报内容")
+    @GetMapping("/copyPreviousReport")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "reportId", value = "周报编号", required = true, dataType = "String"),
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true, dataType = "Integer"),
+            @ApiImplicitParam(name = "reportType", value = "周报类型", required = true)
+    })
+    public ReportContent copyPreviousReport(@RequestParam("reportId") String reportId,
+                                            @RequestParam("projectId") Integer projectId,
+                                            @RequestParam("reportType") ProjectReportType reportType) {
+        switch (reportType) {
+            case PROJECT_REPORT:
+                return contentService.copyPreviousReport(reportId, projectId);
+            case DEVELOPMENT:
+                return developmentService.copyPreviousReport(reportId, projectId);
+            case PRODUCT:
+                return productService.copyPreviousReport(reportId, projectId);
+            case TEST:
+                return testService.copyPreviousReport(reportId, projectId);
+            case CARRY_OUT:
+                return carryOutService.copyPreviousReport(reportId, projectId);
+            case MAPPING:
+                return mappingService.copyPreviousReport(reportId, projectId);
+            default:
+                throw new IllegalArgumentException("周报类型不存在");
+        }
     }
 }

+ 2 - 0
pms-service/src/main/java/com/tofly/pms/supervise/service/ReportContentService.java

@@ -26,4 +26,6 @@ public interface ReportContentService<T extends ReportContent> extends IService<
     long countByReportIdAndProjectId(String reportId, Integer projectId);
 
     T getEntityByNext(String reportId, Integer projectId, String next);
+
+    T copyPreviousReport(String reportId, Integer projectId);
 }

+ 20 - 0
pms-service/src/main/java/com/tofly/pms/supervise/service/impl/ReportContentServiceImpl.java

@@ -243,4 +243,24 @@ public class ReportContentServiceImpl<M extends BaseMapper<T>, T extends ReportC
         }
         return null;
     }
+
+    /**
+     * 根据项目id和周报期数获取上一期的周报内容,修改之后,返回给前端
+     * @param reportId
+     * @param projectId
+     * @return
+     */
+    @Override
+    public T copyPreviousReport(String reportId, Integer projectId) {
+        T lastOne = this.getOne(Wrappers.lambdaQuery(entityClass)
+                .eq(T::getProjectId,projectId)
+                .lt(T::getReportId, reportId)
+                .orderByDesc(T::getReportId)
+                .last("limit 1"));
+        if(Objects.nonNull(lastOne)){
+            lastOne.setId(null);
+            lastOne.setReportId(null);
+        }
+        return lastOne;
+    }
 }