wang-hao-jie
2021-12-08 72ba09f4055bcaadca22530929408a3fcd74ceee
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package cn.exrick.xboot.your.controller.pc;
 
import cn.exrick.xboot.core.common.redis.RedisTemplateHelper;
import cn.exrick.xboot.core.common.utils.PageUtil;
import cn.exrick.xboot.core.common.utils.ResultUtil;
import cn.exrick.xboot.core.common.vo.PageVo;
import cn.exrick.xboot.core.common.vo.Result;
import cn.exrick.xboot.your.entity.Car;
import cn.exrick.xboot.your.entity.EventLog;
import cn.exrick.xboot.your.entity.OrderTask;
import cn.exrick.xboot.your.service.ICarService;
import cn.exrick.xboot.your.service.IEventLogService;
import cn.exrick.xboot.your.service.IOrderTaskService;
import cn.exrick.xboot.your.util.HaiKangPost;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
 
import java.util.*;
 
/**
 * @author whj
 */
@Slf4j
@RestController
@Api(tags = "大屏统计接口")
@RequestMapping("/xboot/pcStatistic")
@Transactional
public class StatisticController {
 
    @Autowired
    private RedisTemplateHelper redisTemplateHelper;
 
    @Autowired
    private IOrderTaskService iOrderTaskService;
 
    @Autowired
    private IEventLogService iEventLogService;
 
    @Autowired
    private ICarService iCarService;
 
    @RequestMapping(value = "/getIndex1", method = RequestMethod.GET)
    @ApiOperation(value = "获取首页数据")
    public Result<Object> getIndex1() {
        Map<String,Object> map = new HashMap<>();
        Set<String> scan = redisTemplateHelper.scan("*statistic1::*");
        for (String str : scan) {
            map.put(str.substring(12),redisTemplateHelper.get(str));
        }
        return new ResultUtil<Object>().setData(map);
    }
 
    @RequestMapping(value = "/getTodayTask", method = RequestMethod.GET)
    @ApiOperation(value = "获取今日配送任务")
    public Result<Object> getTodayTask() {
        QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
        String format = DateUtil.format(new Date(), "yyyy-MM-dd");
        wrapper2.eq("a.send_date",format);
//        wrapper2.orderByAsc("a.seq");
        List<OrderTask> list = iOrderTaskService.list3(format);
        return new ResultUtil<Object>().setData(list);
    }
 
    @RequestMapping(value = "/getEventLog", method = RequestMethod.GET)
    @ApiOperation(value = "获取事件日志")
    public Result<Object> getEventLog() {
        QueryWrapper<EventLog> wrapper2 = new QueryWrapper<EventLog>();
        PageVo page = new PageVo();
        page.setPageNumber(1);
        page.setPageSize(20);
        page.setOrder("desc");
        page.setSort("createTime");
        IPage<EventLog> data = iEventLogService.page(PageUtil.initMpPage(page),wrapper2);
        return new ResultUtil<Object>().setData(data.getRecords());
    }
 
//    @RequestMapping(value = "/getCars", method = RequestMethod.GET)
//    @ApiOperation(value = "获取车辆信息")
//    public Result<Object> getCars() {
//        List<Car> list = iCarService.list();
//        String codes[] = new String[list.size()];
//
//        HaiKangPost.findLatestGps()
//        return new ResultUtil<Object>().setData(data.getRecords());
//    }
}