bug
zhangzeli
2022-01-06 8881c4be7a0d86de2341b489f3ad9e997cb6deb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package cn.exrick.xboot.your.mapper;
import cn.exrick.xboot.your.vo.Month;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.exrick.xboot.your.entity.Car;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
 
import java.util.List;
 
/**
 * 车辆表数据处理层
 * @author zhangzeli
 */
public interface CarMapper extends BaseMapper<Car> {
 
    @Select("SELECT a.*,b1.nickname AS temp,b2.nickname AS followNickName FROM t_car a LEFT JOIN t_user AS b1 ON a.user_id = b1.id LEFT JOIN t_user AS b2 ON a.follow_user_id = b2.id ${ew.customSqlSegment} ")
    @Results({@Result(column="temp", property="nickName", jdbcType = JdbcType.VARCHAR)})
    IPage<Car> page2(Page initMpPage, @Param(Constants.WRAPPER) QueryWrapper<Car> wrapper);
 
    @Select("SELECT c.*,u.nickname,a.`name` AS area_name FROM t_car c LEFT JOIN t_user AS u ON c.user_id=u.id LEFT JOIN t_area AS a ON a.user_id=u.id")
    IPage<Car> getAll2(Page initMpPage);
 
    @Select("SELECT\n" +
            "\tc.*,(SUM(amount)) AS allAmount,SUM(money) AS allMoney,(MAX(mileage)) AS allMileage\n" +
            "FROM\n" +
            "\tt_car c\n" +
            "LEFT JOIN t_add_oil a ON c.id = a.car_id GROUP BY car_no\n")
    List<Car> getCarInfo();
 
    @Select("SELECT\n" +
            "\tc.*,(MAX(amount)-MIN(amount)) AS amount,SUM(money) AS money,(MAX(mileage)-MIN(mileage)) AS mileage\n" +
            "FROM\n" +
            "\tt_car c\n" +
            "LEFT JOIN t_add_oil a ON c.id = a.car_id ${ew.customSqlSegment}")
    List<Car> getCarInfo2(@Param(Constants.WRAPPER) QueryWrapper<Car> wrapper);
 
    @Select("select \n" +
            "sum(case when create_time <= '${year}-01' then 1 else 0 end) as january,\n" +
            "sum(case when create_time <= '${year}-02' then 1 else 0 end) as february,\n" +
            "sum(case when create_time <= '${year}-03' then 1 else 0 end) as march,\n" +
            "sum(case when create_time <= '${year}-04' then 1 else 0 end) as april,\n" +
            "sum(case when create_time <= '${year}-05' then 1 else 0 end) as may,\n" +
            "sum(case when create_time <= '${year}-06' then 1 else 0 end) as june,\n" +
            "sum(case when create_time <= '${year}-07' then 1 else 0 end) as july,\n" +
            "sum(case when create_time <= '${year}-08' then 1 else 0 end) as august,\n" +
            "sum(case when create_time <= '${year}-09' then 1 else 0 end) as september,\n" +
            "sum(case when create_time <= '${year}-10' then 1 else 0 end) as october,\n" +
            "sum(case when create_time <= '${year}-11' then 1 else 0 end) as november,\n" +
            "sum(case when create_time <= '${year}-12' then 1 else 0 end) as december\n" +
            "from t_car")
    Month getCarCount(@Param("year")Integer year);
 
}