智慧农业后台管理
Administrator
2022-05-23 b6879516100bbf87457a69796bc95660baa9e8d0
新增农事操作统计查询接口
5 files modified
1 files added
66 ■■■■■ changed files
src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml 24 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/vo/FarmingStatisVO.java 11 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/farm/controller/FarmingRecordController.java
@@ -131,4 +131,13 @@
        return R.data(farmService.getFarmingCount());
    }
    /**
     * 查询统计本年农事记录操作,按分类统计
     * @return
     */
    @GetMapping("/getFarmingStatis")
    public R getFarmingStatis(){
        return R.data(farmService.getFarmingStatis());
    }
}
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.java
@@ -21,6 +21,7 @@
import org.apache.ibatis.annotations.Param;
import org.springblade.modules.farm.entity.FarmingRecord;
import org.springblade.modules.farm.vo.FarmingRecordVO;
import org.springblade.modules.farm.vo.FarmingStatisVO;
import java.util.List;
@@ -45,4 +46,10 @@
     * @return
     */
    Integer getFarmingCount();
    /**
     * 查询统计本年农事记录操作,按分类统计
     * @return
     */
    List<FarmingStatisVO> getFarmingStatis();
}
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
@@ -30,4 +30,28 @@
        where 1=1
        and YEAR(time)=YEAR(NOW())
    </select>
    <!--查询统计本年农事记录操作总数-->
    <select id="getFarmingStatis" resultType="org.springblade.modules.farm.vo.FarmingStatisVO">
        select
        case when type=0 then '施肥'
         when type=1 then '翻耕'
         when type=2 then '灌溉'
         when type=3 then '起垄'
         when type=4 then '用药'
         when type=5 then '追肥'
         when type=6 then '除草'
         when type=7 then '修剪'
         when type=8 then '浸种'
         when type=9 then '拌种'
         when type=10 then '移栽'
         when type=11 then '直播'
         when type=12 then '采收'
         else '其他' end as name,
        ifnull(count(*),0) value
        from sys_farming_record
        where 1=1
        and YEAR(time)=YEAR(NOW())
        group by type
    </select>
</mapper>
src/main/java/org/springblade/modules/farm/service/FarmingRecordService.java
@@ -27,4 +27,10 @@
     * @return
     */
    Object getFarmingCount();
    /**
     * 查询统计本年农事记录操作,按分类统计
     * @return
     */
    Object getFarmingStatis();
}
src/main/java/org/springblade/modules/farm/service/impl/FarmRecordServiceImpl.java
@@ -35,4 +35,13 @@
    public Object getFarmingCount() {
        return baseMapper.getFarmingCount();
    }
    /**
     * 查询统计本年农事记录操作,按分类统计
     * @return
     */
    @Override
    public Object getFarmingStatis() {
        return baseMapper.getFarmingStatis();
    }
}
src/main/java/org/springblade/modules/farm/vo/FarmingStatisVO.java
New file
@@ -0,0 +1,11 @@
package org.springblade.modules.farm.vo;
import lombok.Data;
@Data
public class FarmingStatisVO {
    private String name;
    private Integer value;
}