From a71bc7d6b21e373fb6f17c08bc93b866ea977714 Mon Sep 17 00:00:00 2001 From: "WIN-IDGBLFHC1K6\\Administrator" <787952492@qq.com> Date: Thu, 30 Jun 2022 10:26:17 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=9B=BE=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistical/StatisticalController.java | 27 ++++++++++++++----- .../admin/statistical/vo/CakeSeries.java | 2 +- .../service/project/ProjectServiceImpl.java | 3 --- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java index b2504263..ca5e490b 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java @@ -5,9 +5,11 @@ import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.farm.controller.admin.statistical.dto.RequestDTO; import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.*; +import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO; import cn.iocoder.yudao.module.farm.dal.dataobject.crop.CropDO; import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; +import cn.iocoder.yudao.module.farm.dal.mysql.area.AreaMapper; import cn.iocoder.yudao.module.farm.dal.mysql.crop.CropMapper; import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper; import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper; @@ -45,6 +47,8 @@ public class StatisticalController { private CpUserMapper cpUserMapper; @Resource private CropMapper cropMapper; + @Resource + private AreaMapper areaMapper; @PostMapping("/statisticalInformation") @ApiOperation("农场数据统计接口") @@ -89,7 +93,7 @@ public class StatisticalController { //任务数据 - List taskList = taskMapper.selectList(); + List taskList = taskMapper.selectList(Wrappers.lambdaQuery().eq(TaskDO::getPretendDelete, false).eq(TaskDO::getDraft, false)); vo.setTaskTotalCount(taskList.size()); Long planeCount = taskList.stream().filter(plane -> plane.getStatus().equals(TaskStatus.PLAN) || plane.getStatus().equals(TaskStatus.READY)).count(); vo.setTaskPlanCount(planeCount.intValue()); @@ -102,25 +106,34 @@ public class StatisticalController { //种植数量 饼状图 //根据工时获取所有的活动 - List workTaskIdList = workList.stream().map(WorkHourDO::getTaskId).collect(Collectors.toList()); - List finishTaskList = taskList.stream().filter(item -> workTaskIdList.contains(item.getId())).collect(Collectors.toList()); - List cropIdList = finishTaskList.stream().filter(item -> item.getStatus().equals(TaskStatus.COMPLETE)).map(TaskDO::getCropId).collect(Collectors.toList()); + List finishTaskList = taskList.stream().filter(item -> item.getStatus().equals(TaskStatus.COMPLETE)).collect(Collectors.toList()); + List cropIdList = finishTaskList.stream().map(TaskDO::getCropId).collect(Collectors.toList()); if (ObjectUtils.isEmpty(cropIdList)){ vo.setCakeSeries(new ArrayList<>()); }else { List cropList = cropMapper.selectList(Wrappers.lambdaQuery().in(CropDO::getId, cropIdList)); + List areaList = areaMapper.selectList(Wrappers.lambdaQuery().eq(AreaDO::getPretendDelete, false).ne(AreaDO::getParentId, 0)); Map cropMap = new HashMap<>(); for (TaskDO taskDO : finishTaskList) { for (CropDO cropDO : cropList) { if (taskDO.getCropId().equals(cropDO.getId())){ + //这里是算 这个任务所选区域的总面积 + Double areaSum = new Double(0); + for (Long areaId : taskDO.getAreas()) { + List areaDOS = areaList.stream().filter(area -> area.getId().equals(areaId)).collect(Collectors.toList()); + if (ObjectUtil.isNotEmpty(areaDOS)){ + areaSum += areaDOS.stream().mapToDouble(AreaDO::getArea).sum(); + } + } + //饼状图 作物名 if (cropMap.containsKey(cropDO.getId())){ CakeSeries cakeSeries = cropMap.get(cropDO.getId()); - cakeSeries.setValue(cakeSeries.getValue() + (taskDO.getCropNum() == null ? 0 : taskDO.getCropNum())); + cakeSeries.setValue(cakeSeries.getValue() + areaSum); }else{ CakeSeries cakeSeries = CakeSeries.builder() .name(cropDO.getName()) - .value(taskDO.getCropNum() == null ? 0 : taskDO.getCropNum()) + .value(areaSum) .labelText("不知道说啥") .build(); cropMap.put(cropDO.getId(), cakeSeries); @@ -137,7 +150,7 @@ public class StatisticalController { } vo.setCakeTitle("总数量"); - vo.setCakeSubtitle(vo.getCakeSeries().stream().mapToInt(CakeSeries::getValue).sum() + "颗"); + vo.setCakeSubtitle(vo.getCakeSeries().stream().mapToDouble(CakeSeries::getValue).sum()+"平方"); return CommonResult.success(vo); } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java index 17f1756a..f8b8d334 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java @@ -12,7 +12,7 @@ import lombok.NoArgsConstructor; public class CakeSeries { private String name; - private Integer value; + private Double value; private String labelText; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java index 0c2437fe..54b25f12 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java @@ -164,9 +164,6 @@ public class ProjectServiceImpl implements ProjectService { pageParam.setPageNo(pageDTO.getPageNum()); pageParam.setPageSize(pageDTO.getPageSize()); List list = projectMapper.selectPage(pageParam, queryWrapperX).getList(); - -// List list = projectMapper.selectPage(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), queryWrapperX).getRecords(); - if (ObjectUtil.isEmpty(list)){ return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class)); }