| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | 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.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | |
| | | @Resource |
| | | private RestTemplate restTemplate; |
| | | |
| | | @Resource |
| | | private TPlatformConfigService platformConfigService; |
| | | |
| | | /** 登录华为 FusionSolar 并取得 XSRF-TOKEN。 */ |
| | | public String getXsrfToken() { |
| | | return getXsrfToken(DEFAULT_USER_NAME, DEFAULT_SYSTEM_CODE); |
| | | TPlatformConfig config = platformConfigService.getOne(Wrappers.lambdaQuery(TPlatformConfig.class).eq(TPlatformConfig::getPlatformName, "华为")); |
| | | if (config == null || StringUtils.isBlank(config.getAccount()) || StringUtils.isBlank(config.getPassword())) { |
| | | return getXsrfToken(DEFAULT_USER_NAME, DEFAULT_SYSTEM_CODE); |
| | | } |
| | | return getXsrfToken(config.getAccount(), config.getPassword()); |
| | | } |
| | | |
| | | /** 使用指定账号登录并取得 XSRF-TOKEN。 */ |