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) {
|
}
|
}
|
}
|