|
|
@ -5,9 +5,11 @@ import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
|
|
|
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.dto.RequestDTO; |
|
|
|
import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.*; |
|
|
|
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.crop.CropDO; |
|
|
|
import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; |
|
|
|
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.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.crop.CropMapper; |
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper; |
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper; |
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper; |
|
|
|
import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper; |
|
|
@ -45,6 +47,8 @@ public class StatisticalController { |
|
|
|
private CpUserMapper cpUserMapper; |
|
|
|
private CpUserMapper cpUserMapper; |
|
|
|
@Resource |
|
|
|
@Resource |
|
|
|
private CropMapper cropMapper; |
|
|
|
private CropMapper cropMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
|
|
|
|
private AreaMapper areaMapper; |
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/statisticalInformation") |
|
|
|
@PostMapping("/statisticalInformation") |
|
|
|
@ApiOperation("农场数据统计接口") |
|
|
|
@ApiOperation("农场数据统计接口") |
|
|
@ -89,7 +93,7 @@ public class StatisticalController { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//任务数据
|
|
|
|
//任务数据
|
|
|
|
List<TaskDO> taskList = taskMapper.selectList(); |
|
|
|
List<TaskDO> taskList = taskMapper.selectList(Wrappers.<TaskDO>lambdaQuery().eq(TaskDO::getPretendDelete, false).eq(TaskDO::getDraft, false)); |
|
|
|
vo.setTaskTotalCount(taskList.size()); |
|
|
|
vo.setTaskTotalCount(taskList.size()); |
|
|
|
Long planeCount = taskList.stream().filter(plane -> plane.getStatus().equals(TaskStatus.PLAN) || plane.getStatus().equals(TaskStatus.READY)).count(); |
|
|
|
Long planeCount = taskList.stream().filter(plane -> plane.getStatus().equals(TaskStatus.PLAN) || plane.getStatus().equals(TaskStatus.READY)).count(); |
|
|
|
vo.setTaskPlanCount(planeCount.intValue()); |
|
|
|
vo.setTaskPlanCount(planeCount.intValue()); |
|
|
@ -102,25 +106,34 @@ public class StatisticalController { |
|
|
|
|
|
|
|
|
|
|
|
//种植数量 饼状图
|
|
|
|
//种植数量 饼状图
|
|
|
|
//根据工时获取所有的活动
|
|
|
|
//根据工时获取所有的活动
|
|
|
|
List<Long> workTaskIdList = workList.stream().map(WorkHourDO::getTaskId).collect(Collectors.toList()); |
|
|
|
List<TaskDO> finishTaskList = taskList.stream().filter(item -> item.getStatus().equals(TaskStatus.COMPLETE)).collect(Collectors.toList()); |
|
|
|
List<TaskDO> finishTaskList = taskList.stream().filter(item -> workTaskIdList.contains(item.getId())).collect(Collectors.toList()); |
|
|
|
List<Long> cropIdList = finishTaskList.stream().map(TaskDO::getCropId).collect(Collectors.toList()); |
|
|
|
List<Long> cropIdList = finishTaskList.stream().filter(item -> item.getStatus().equals(TaskStatus.COMPLETE)).map(TaskDO::getCropId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
if (ObjectUtils.isEmpty(cropIdList)){ |
|
|
|
if (ObjectUtils.isEmpty(cropIdList)){ |
|
|
|
vo.setCakeSeries(new ArrayList<>()); |
|
|
|
vo.setCakeSeries(new ArrayList<>()); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
List<CropDO> cropList = cropMapper.selectList(Wrappers.<CropDO>lambdaQuery().in(CropDO::getId, cropIdList)); |
|
|
|
List<CropDO> cropList = cropMapper.selectList(Wrappers.<CropDO>lambdaQuery().in(CropDO::getId, cropIdList)); |
|
|
|
|
|
|
|
List<AreaDO> areaList = areaMapper.selectList(Wrappers.<AreaDO>lambdaQuery().eq(AreaDO::getPretendDelete, false).ne(AreaDO::getParentId, 0)); |
|
|
|
Map<Long, CakeSeries> cropMap = new HashMap<>(); |
|
|
|
Map<Long, CakeSeries> cropMap = new HashMap<>(); |
|
|
|
for (TaskDO taskDO : finishTaskList) { |
|
|
|
for (TaskDO taskDO : finishTaskList) { |
|
|
|
for (CropDO cropDO : cropList) { |
|
|
|
for (CropDO cropDO : cropList) { |
|
|
|
if (taskDO.getCropId().equals(cropDO.getId())){ |
|
|
|
if (taskDO.getCropId().equals(cropDO.getId())){ |
|
|
|
|
|
|
|
//这里是算 这个任务所选区域的总面积
|
|
|
|
|
|
|
|
Double areaSum = new Double(0); |
|
|
|
|
|
|
|
for (Long areaId : taskDO.getAreas()) { |
|
|
|
|
|
|
|
List<AreaDO> 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())){ |
|
|
|
if (cropMap.containsKey(cropDO.getId())){ |
|
|
|
CakeSeries cakeSeries = cropMap.get(cropDO.getId()); |
|
|
|
CakeSeries cakeSeries = cropMap.get(cropDO.getId()); |
|
|
|
cakeSeries.setValue(cakeSeries.getValue() + (taskDO.getCropNum() == null ? 0 : taskDO.getCropNum())); |
|
|
|
cakeSeries.setValue(cakeSeries.getValue() + areaSum); |
|
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
}else{ |
|
|
|
CakeSeries cakeSeries = CakeSeries.builder() |
|
|
|
CakeSeries cakeSeries = CakeSeries.builder() |
|
|
|
.name(cropDO.getName()) |
|
|
|
.name(cropDO.getName()) |
|
|
|
.value(taskDO.getCropNum() == null ? 0 : taskDO.getCropNum()) |
|
|
|
.value(areaSum) |
|
|
|
.labelText("不知道说啥") |
|
|
|
.labelText("不知道说啥") |
|
|
|
.build(); |
|
|
|
.build(); |
|
|
|
cropMap.put(cropDO.getId(), cakeSeries); |
|
|
|
cropMap.put(cropDO.getId(), cakeSeries); |
|
|
@ -137,7 +150,7 @@ public class StatisticalController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
vo.setCakeTitle("总数量"); |
|
|
|
vo.setCakeTitle("总数量"); |
|
|
|
vo.setCakeSubtitle(vo.getCakeSeries().stream().mapToInt(CakeSeries::getValue).sum() + "颗"); |
|
|
|
vo.setCakeSubtitle(vo.getCakeSeries().stream().mapToDouble(CakeSeries::getValue).sum()+"平方"); |
|
|
|
|
|
|
|
|
|
|
|
return CommonResult.success(vo); |
|
|
|
return CommonResult.success(vo); |
|
|
|
} |
|
|
|
} |
|
|
|