Browse Source

统计接口

zyh
Loki 3 years ago
parent
commit
7a6f346404
  1. 77
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java
  2. 18
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java
  3. 12
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/ChartData.java
  4. 13
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/Series.java
  5. 35
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/StatisticalVo.java

77
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/StatisticalController.java

@ -0,0 +1,77 @@
package cn.iocoder.yudao.module.farm.controller.admin.statistical;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.CakeSeries;
import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.ChartData;
import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.Series;
import cn.iocoder.yudao.module.farm.controller.admin.statistical.vo.StatisticalVo;
import cn.iocoder.yudao.module.farm.dal.dataobject.project.ProjectDO;
import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper;
import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper;
import cn.iocoder.yudao.module.farm.service.project.ProjectService;
import cn.iocoder.yudao.module.farm.service.task.TaskService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
@Slf4j
@RestController
@Api(tags = "回乡农场 - 统计")
@RequestMapping("/statistical")
@Validated
public class StatisticalController {
@Resource
private ProjectMapper projectMapper;
@Resource
private TaskMapper taskMapper;
@GetMapping("/index")
@ApiOperation("统计首页接口")
public CommonResult<StatisticalVo> index(){
LoginUser user = SecurityFrameworkUtils.getLoginUser();
StatisticalVo vo = new StatisticalVo();
vo.setProjectTotalCount(111);
vo.setProjectPlanCount(23);
vo.setProjectStartingCount(12);
vo.setProjectCompleteCount(69);
ChartData chartData = new ChartData();
chartData.setCategories(Lists.newArrayList("a","b","c"));
Series series = new Series();
series.setName("销量");
series.setData(Lists.newArrayList(1L,2L,3L,4L,5L));
chartData.setSeries(Lists.newArrayList(series));
vo.setStripData(chartData);
vo.setCakeTitle("总面积");
vo.setCakeSubtitle("333m²");
CakeSeries cakeSeries1 = CakeSeries.builder().name("A").value(10.00).labelText("A类").build();
CakeSeries cakeSeries2 = CakeSeries.builder().name("B").value(20.00).labelText("B类").build();
CakeSeries cakeSeries3 = CakeSeries.builder().name("C").value(30.00).labelText("C类").build();
CakeSeries cakeSeries4 = CakeSeries.builder().name("D").value(40.00).labelText("D类").build();
ArrayList<CakeSeries> cakeSeriesList = Lists.newArrayList(cakeSeries1, cakeSeries2, cakeSeries3, cakeSeries4);
vo.setCakeSeries(cakeSeriesList);
return CommonResult.success(vo);
}
}

18
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/CakeSeries.java

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.farm.controller.admin.statistical.vo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CakeSeries {
private String name;
private Double value;
private String labelText;
}

12
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/ChartData.java

@ -0,0 +1,12 @@
package cn.iocoder.yudao.module.farm.controller.admin.statistical.vo;
import lombok.Data;
import java.util.List;
@Data
public class ChartData {
private List<String> categories;
private List<Series> series;
}

13
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/Series.java

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.farm.controller.admin.statistical.vo;
import lombok.Data;
import java.util.List;
@Data
public class Series {
private String name;
private List<Long> data;
}

35
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/statistical/vo/StatisticalVo.java

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.farm.controller.admin.statistical.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class StatisticalVo {
@ApiModelProperty("项目总数")
private Integer projectTotalCount;
@ApiModelProperty("项目计划数量")
private Integer projectPlanCount;
@ApiModelProperty("项目启动数")
private Integer projectStartingCount;
@ApiModelProperty("项目完成数")
private Integer projectCompleteCount;
@ApiModelProperty("条状数据图")
private ChartData stripData;
@ApiModelProperty("饼图中间标题")
private String cakeTitle;
@ApiModelProperty("饼图值")
private String cakeSubtitle;
@ApiModelProperty("饼图数据")
private List<CakeSeries> cakeSeries;
}
Loading…
Cancel
Save