diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/DiscussController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/DiscussController.java index e3e96e76..2a7c945a 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/DiscussController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/discuss/DiscussController.java @@ -110,4 +110,9 @@ public class DiscussController { return discussService.findDiscussList(pageDTO); } + @ApiModelProperty("根据taskId查询累计的任务时长") + @GetMapping("/cumulativeQuantity") + public R cumulativeQuantity(@RequestParam("taskId") Long taskId){ + return discussService.cumulativeQuantity(taskId); + } } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussService.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussService.java index a9675fec..81674a3a 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussService.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussService.java @@ -75,4 +75,9 @@ public interface DiscussService { R> findDiscussList(DiscussPageDTO pageDTO); + /** + * 根据taskId查询累计的任务时长 + **/ + R cumulativeQuantity(Long taskId); + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java index f58f25f9..91a1d915 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java @@ -209,4 +209,11 @@ public class DiscussServiceImpl implements DiscussService { return R.success(returnList); } + public R cumulativeQuantity(Long taskId){ + List discussDOList = discussMapper.selectList(DiscussDO::getTaskId, taskId); + if (ObjectUtil.isEmpty(discussDOList)){ + return R.success(0); + } + return R.success(discussDOList.stream().mapToInt(DiscussDO::getCropNum).sum()); + } }