| | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.utils.SpringUtils; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.other.domain.TPlatformConfig; |
| | | import com.ruoyi.other.service.TPlatformConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | |
| | | public static String token() { |
| | | TPlatformConfig config = SpringUtils.getBean(TPlatformConfigService.class).getOne(Wrappers.lambdaQuery(TPlatformConfig.class).eq(TPlatformConfig::getPlatformName, "科士达")); |
| | | if (config == null) { |
| | | config = new TPlatformConfig(); |
| | | } |
| | | if (StringUtils.isBlank(config.getAccount()) || StringUtils.isBlank(config.getPassword())) { |
| | | config.setAccount("环岛光伏"); |
| | | config.setPassword("cR8GGwIXMI462A8Dfl9eXg=="); |
| | | } |
| | | HttpRequest post = HttpUtil.createPost("http://111.230.136.62:8092/authentication/form"); |
| | | post.basicAuth("kstar","kstarSecret"); |
| | | post.form("username", "环岛光伏"); |
| | | post.form("password", "cR8GGwIXMI462A8Dfl9eXg=="); |
| | | System.out.println(post); |
| | | post.form("username", config.getAccount()); |
| | | post.form("password", config.getPassword()); |
| | | HttpResponse execute = post.execute(); |
| | | String body = execute.body(); |
| | | JSONObject jsonObject = JSONObject.parseObject(body); |
| | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |