mitao
2025-11-14 e8aca793b8df367dc114ef96d33d6188f7c076b5
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
package com.stylefeng.guns.modular.system.controller.general;
 
import com.alibaba.fastjson.JSONObject;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.modular.system.model.Dict;
import com.stylefeng.guns.modular.system.response.GaoDeDayBaseQuotaUsageVo;
import com.stylefeng.guns.modular.system.response.TencentMapDayBaseQuotaUsageVo;
import com.stylefeng.guns.modular.system.service.IDictService;
import com.stylefeng.guns.modular.system.util.MapDispatchUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * 地图接口调度器
 *
 * @author Maple
 * @Date 2024/12/12 17:02
 */
@RestController
@RequestMapping("/mapDispatch")
public class MapDispatchController extends BaseController {
    @Autowired
    private IDictService dictService;
    @Autowired
    private MapDispatchUtil mapDispatchUtil;
 
    /**
     * 获取地图Key
     * <p>
     * //     * @param serverName 服务名称(管理端、司机端、用户端)
     *
     * @param mapType      地图类型:0=高德 | 1=腾讯
     * @param mapServiceID 服务ID
     * @return
     */
    @GetMapping(value = "/getMapKey")
    public Object getMapKey(@RequestParam("mapType") String mapType, @RequestParam("mapServiceID") int mapServiceID, @RequestParam("mapServiceType") String mapServiceType) {
        //旧代码Begin
//        List<Dict> dictList = dictService.selectByCode(serverName);
//        if (dictList == null || dictList.isEmpty()) {
//            return null;
//        } else {
//            return dictList.get(0).getName();
//        }
        //旧代码End
 
        return mapDispatchUtil.getMapKey(mapType, mapServiceID, mapServiceType);
    }
 
    /**
     * 获取输入提示Key
     *
     * @param serverName 服务名称(管理端、司机端、用户端)
     * @param apiName    API名称(inputtips:输入提示)
     * @return
     */
    @GetMapping(value = "/getInputtips")
    public String getInputtips(@RequestParam("serverName") String serverName, @RequestParam("apiName") String apiName) {
        switch (apiName) {
            case "inputtips":
                //切换新的key
                return getInputtips();
            default:
                return "";
        }
    }
 
    /**
     * 刷新输入提示Key
     *
     * @param serverName 服务名称(管理端、司机端、用户端)
     * @param apiName    API名称(inputtips:输入提示)
     * @return
     */
    @GetMapping(value = "/refreshInputtips")
    public void refreshInputtips(@RequestParam("serverName") String serverName, @RequestParam("apiName") String apiName) {
        switch (apiName) {
            case "inputtips":
                //切换新的key
                switchinputtips();
                break;
        }
    }
 
    @GetMapping(value = "/getGaoDeAPIUsage")
    public String getGaoDeAPIUsage(@RequestParam("gaoDeAccountID") String gaoDeAccountID) {
//        GaoDeDayBaseQuotaUsageVo gaoDeAPIUsage = mapDispatchUtil.getGaoDeDayBaseQuotaUsage(gaoDeAccountID);
//        mapDispatchUtil.updateGaoDeDayBaseQuotaUsage(gaoDeAccountID, gaoDeAPIUsage);
        mapDispatchUtil.updateGaoDeDayBaseQuotaUsageBatch();
        return "OK";
    }
 
    @GetMapping(value = "/getTencentMapAPIUsage")
    public String getTencentMapAPIUsage(@RequestParam("tencentAccountID") String tencentAccountID) {
//        TencentMapDayBaseQuotaUsageVo tencentMapDayBaseQuotaUsageVo = mapDispatchUtil.getTencentMapDayBaseQuotaUsage(tencentAccountID);
//        mapDispatchUtil.updateTencentMapDayBaseQuotaUsage(tencentAccountID, tencentMapDayBaseQuotaUsageVo);
        mapDispatchUtil.updateTencentMapDayBaseQuotaUsageBatch();
        return "OK";
    }
 
    private String getInputtips() {
        List<Dict> dictList = dictService.selectByCode("gaode_inputtips_switch");
        if (dictList == null || dictList.isEmpty()) {
            return "";
        }
        try {
            int index = Integer.parseInt(dictList.get(0).getName());
            Dict indexdic = dictList.get(0);
            dictList.clear();
            Dict dict = dictService.selectByChildrenCode("gaode_inputtips", indexdic.getName());
            if (dict == null) {
                return "";
            } else {
                return dict.getName();
            }
        } catch (NumberFormatException ignored) {
            return "";
        }
    }
 
    private void switchinputtips() {
        List<Dict> dictList = dictService.selectByCode("gaode_inputtips_switch");
        if (dictList == null || dictList.isEmpty()) {
            return;
        }
        try {
            int index = Integer.parseInt(dictList.get(0).getName());
            Dict indexdic = dictList.get(0);
            dictList.clear();
            dictList = dictService.selectByParentCode("gaode_inputtips");
            if (dictList.isEmpty()) {
                return;
            }
            if (index == 0) {
                indexdic.setName("1");
                dictService.updateById(indexdic);
            } else if (index < dictList.size()) {
                indexdic.setName(String.valueOf(++index));
                dictService.updateById(indexdic);
            } else {
                System.out.println("高德【输入提示】Key池已用尽!");
            }
        } catch (NumberFormatException ignored) {
        }
    }
}