xuhy
2023-04-03 bec9ef7332b0c0d1afc9b28918748efc63a60bcc
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package com.stylefeng.guns.modular.system.controller.general;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.common.constant.state.Order;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.modular.system.controller.resp.TOrderServerResp;
import com.stylefeng.guns.modular.system.enums.OrderStateEnum;
import com.stylefeng.guns.modular.system.model.TAgent;
import com.stylefeng.guns.modular.system.model.TDriver;
import com.stylefeng.guns.modular.system.model.TOrder;
import com.stylefeng.guns.modular.system.service.*;
import com.stylefeng.guns.modular.system.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
 
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
 
/**
 * 控制器
 *
 * @author fengshuonan
 * @Date 2023-03-14 15:15:19
 */
@Controller
@RequestMapping("/tHomePage")
public class THomePageController extends BaseController {
 
    @Autowired
    private IUserService userService;
    @Autowired
    private ITAgentService tAgentService;
    @Autowired
    private ITDriverService tDriverService;
    @Autowired
    private ITOrderService tOrderService;
    @Autowired
    private ITRevenueService tRevenueService;
 
    private String PREFIX = "/system/tHomePage/";
 
    /**
     * 跳转到地图
     */
    @RequestMapping("/map")
    public String map(Integer agentId,Integer type,Model model) {
 
        if(Objects.nonNull(agentId)){
            // 查询统计在线司机,待接单,服务中,已完成,已取消
            Map<String,Integer> map = new HashMap<>(4);
            int serverCount = tDriverService.selectCount(new EntityWrapper<TDriver>()
                    .eq("agentId", agentId)
                    .eq("serverStatus", 2));
            tOrderService.getDataStatisticsCount(agentId,map);
            model.addAttribute("map",map);
 
            // 查询服务中的订单列表
            List<TOrderServerResp> orderServerRespList = tOrderService.getDataStatisticsServerList(agentId);
            model.addAttribute("serverList",orderServerRespList);
 
            // 查询今天所有订单
            List<TOrder> allList = tOrderService.getDataStatisticsAllList(agentId);
 
            // TODO 拿到所有司机地址
 
        }else {
            // TODO 查询广东全区域数据
        }
 
        return PREFIX + "tHomePageMap.html";
    }
 
    /**
     * 跳转到首页统计
     */
    @RequestMapping("/statistics")
    public String statistics(Integer agentId,String dayDate,String yearDate,String monthDate,Integer type,Model model) {
        model.addAttribute("txt",new SimpleDateFormat("yyyy年MM月dd日").format(new Date()) + DateUtil.getWeekDay(new Date()) + ",欢迎" +
                Objects.requireNonNull(ShiroKit.getUser()).getName() + "登录");
        if(Objects.nonNull(agentId)){
            // 统计代理商
            tAgentService.getDataStatistics(agentId,model);
 
            // 统计司机数
            tDriverService.getDataStatistics(agentId,model);
 
            // TODO 订单统计:按今天,昨天,本周,本月
 
            // 订单统计,每年按月份
            tOrderService.getDataStatisticsByYear(agentId,yearDate,model);
 
            // 业绩排名 performanceTable
            if (1 == type){
                // 单量
                tOrderService.getDataStatisticsOrderCount(agentId,monthDate,model);
            }else {
                // 收入、佣金
                tRevenueService.getDataStatisticsIncomeOrCommission(agentId,monthDate,type,model);
            }
 
        }else {
            // TODO 查询广东全区域数据
        }
        return PREFIX + "tHomePageStatistics.html";
    }
 
}