11
13693261870
2024-11-05 0f4da6101dd8552cc91475b1a0468e2847316c7d
src/main/java/com/se/simu/service/GedbService.java
@@ -10,6 +10,7 @@
import com.se.simu.domain.dto.GeFile;
import com.se.simu.domain.dto.GeLayer;
import com.se.simu.domain.po.DataPo;
import com.se.simu.helper.CaffeineHelper;
import com.se.simu.helper.RsaHelper;
import com.se.simu.helper.ShpHelper;
import com.se.simu.helper.StringHelper;
@@ -51,6 +52,8 @@
    @Resource
    RestTemplate restTemplate;
    private final static String TOKEN_KEY = "gedb_token";
    public boolean test(DataPo data) throws Exception {
        createPath(config.getInPath() + File.separator + data.getInPath());
@@ -73,11 +76,26 @@
    }
    public String getToken() throws Exception {
        Object obj = CaffeineHelper.get(TOKEN_KEY);
        if (obj instanceof String) {
            return obj.toString();
        }
        String token = getTokenByServer();
        if (null == token) throw new Exception("获取GEDB令牌失败");
        CaffeineHelper.put(TOKEN_KEY, token);
        return token;
    }
    private String getTokenByServer() throws Exception {
        Map<String, Object> map = new HashMap<>(2);
        map.put("userid", config.getUser());
        map.put("password", getPassword());
        JSONObject obj = restTemplate.postForObject(config.getHost() + "account-service/security/login", map, JSONObject.class);
        log.info(obj.toString());
        JSONObject data = obj.getJSONObject("data");