Explorar o código

feat: 实现车辆资源地图车辆类型统计接口

weijianghai hai 1 ano
pai
achega
4a20cdafb3

+ 1 - 1
pom.xml

@@ -55,7 +55,7 @@
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.5.3.2</version>
+            <version>3.5.4.1</version>
         </dependency>
         <!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
         <dependency>

+ 8 - 0
src/main/java/com/nokia/financeapi/controller/car/CarResourceMapController.java

@@ -2,7 +2,9 @@ package com.nokia.financeapi.controller.car;
 
 import com.nokia.financeapi.common.R;
 import com.nokia.financeapi.pojo.dto.GetCarNoticeDto;
+import com.nokia.financeapi.pojo.dto.GetCarTypeStatDto;
 import com.nokia.financeapi.pojo.vo.GetCarNoticeVo;
+import com.nokia.financeapi.pojo.vo.GetCarTypeStatVo;
 import com.nokia.financeapi.service.car.CarResourceMapService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -29,4 +31,10 @@ public class CarResourceMapController {
     public R<List<GetCarNoticeVo>> getNotice(@Valid @RequestBody GetCarNoticeDto dto) {
         return carResourceMapService.getNotice(dto);
     }
+
+    @Operation(summary = "获取车辆类型统计")
+    @PostMapping("/getCarTypeStat")
+    public R<GetCarTypeStatVo> getCarTypeStat(@Valid @RequestBody GetCarTypeStatDto dto) {
+        return carResourceMapService.getCarTypeStat(dto);
+    }
 }

+ 28 - 0
src/main/java/com/nokia/financeapi/dao/car/CarResourceMapMapper.java

@@ -1,7 +1,9 @@
 package com.nokia.financeapi.dao.car;
 
 import com.nokia.financeapi.pojo.dto.GetCarNoticeDto;
+import com.nokia.financeapi.pojo.dto.GetCarTypeStatDto;
 import com.nokia.financeapi.pojo.vo.GetCarNoticeVo;
+import com.nokia.financeapi.pojo.vo.GetCarTypeStatVo;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
@@ -19,4 +21,30 @@ where city = #{dto.city}
 order by create_time desc
 """)
     List<GetCarNoticeVo> getNotice(@Param("dto") GetCarNoticeDto dto);
+
+    /**
+     * 获取全省或某个地市的车辆类型统计
+     */
+    @Select("""
+<script>
+select
+    count(che_liang_lei_xing = '皮卡车' or null) as pkc,
+    count(che_liang_lei_xing = '微型面包车' or null) as wxmbc,
+    count(che_liang_lei_xing = '越野车' or null) as yyc,
+    count(che_liang_lei_xing = '轿车' or null) as jc,
+    count(che_liang_lei_xing not in ('皮卡车', '微型面包车', '越野车', '轿车') or null) as qtc
+from
+    car.car_base_data_month
+where
+    nian_yue = (
+    select
+        max(nian_yue)
+    from
+        car.car_base_data_month)
+    <if test="dto.city != null and dto.city != ''">
+      and city = #{dto.city}
+    </if>
+</script>
+""")
+    GetCarTypeStatVo getCarTypeStat(@Param("dto") GetCarTypeStatDto dto);
 }

+ 10 - 0
src/main/java/com/nokia/financeapi/pojo/dto/GetCarTypeStatDto.java

@@ -0,0 +1,10 @@
+package com.nokia.financeapi.pojo.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class GetCarTypeStatDto {
+    @Schema(description = "地市,不传默认全省", example = "石家庄")
+    private String city;
+}

+ 18 - 0
src/main/java/com/nokia/financeapi/pojo/vo/GetCarTypeStatVo.java

@@ -0,0 +1,18 @@
+package com.nokia.financeapi.pojo.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class GetCarTypeStatVo {
+    @Schema(description = "皮卡车数量", example = "22")
+    private Integer pkc;
+    @Schema(description = "微型面包车数量", example = "22")
+    private Integer wxmbc;
+    @Schema(description = "越野车数量", example = "22")
+    private Integer yyc;
+    @Schema(description = "轿车数量", example = "22")
+    private Integer jc;
+    @Schema(description = "其他数量", example = "22")
+    private Integer qtc;
+}

+ 7 - 0
src/main/java/com/nokia/financeapi/service/car/CarResourceMapService.java

@@ -3,7 +3,9 @@ package com.nokia.financeapi.service.car;
 import com.nokia.financeapi.common.R;
 import com.nokia.financeapi.dao.car.CarResourceMapMapper;
 import com.nokia.financeapi.pojo.dto.GetCarNoticeDto;
+import com.nokia.financeapi.pojo.dto.GetCarTypeStatDto;
 import com.nokia.financeapi.pojo.vo.GetCarNoticeVo;
+import com.nokia.financeapi.pojo.vo.GetCarTypeStatVo;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -24,4 +26,9 @@ public class CarResourceMapService {
         List<GetCarNoticeVo> vo = carResourceMapMapper.getNotice(dto);
         return R.ok(vo);
     }
+
+    public R<GetCarTypeStatVo> getCarTypeStat(GetCarTypeStatDto dto) {
+        GetCarTypeStatVo vo = carResourceMapMapper.getCarTypeStat(dto);
+        return R.ok(vo);
+    }
 }