沙钢智慧能源系统后端代码
dongyukun
5 天以前 8083603f27daa6840b93d36767d4e7d45ccd256e
shasteel-biz/src/main/java/com/iailab/module/shasteel/job/task/SyncSegmentedDataTask.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.iailab.framework.common.util.date.DateUtils;
import com.iailab.framework.common.util.http.HttpUtils;
import com.iailab.module.model.api.mcs.McsApi;
import com.iailab.module.model.api.mcs.dto.ElectricityPriceSegmentedDTO;
@@ -37,11 +38,11 @@
    @Autowired
    private RabbitTemplate rabbitTemplate;
    private static final String PUBLIC_KEY_URL = "http://10.88.7.107:8081/api/api/services/Runtime/Authentication/GetLoginRSAPublicKeyAsync";
    private static final String PUBLIC_KEY_URL = "http://zhny.shasteel.cn/api/api/services/Runtime/Authentication/GetLoginRSAPublicKeyAsync";
    private static final String ACCESS_TOKEN_URL = "http://10.88.7.107:8081/EP.Web/account/ajaxLogin";
    private static final String ACCESS_TOKEN_URL = "http://zhny.shasteel.cn/EP.Web/account/ajaxLogin";
    private static final String QUERY_SEGMENTED_DATA_URL = "http://10.88.7.107:8081/SG.Web/api/services/nYJK/DiagnosticsSg/QuerySegmentedDataAsync";
    private static final String QUERY_SEGMENTED_DATA_URL = "http://zhny.shasteel.cn/SG.Web/api/services/nYJK/DiagnosticsSg/QuerySegmentedDataAsync";
    private static final String USERNAME = "Mx001@sgis";
@@ -77,7 +78,7 @@
            mcsApi.createElectricityPrice(list);
            logger.info("保存数据完成");
        } catch (Exception ex) {
            logger.error("syncSegmentedDataTask运行异常");
            logger.error("syncSegmentedDataTask运行异常:" + ex.getMessage());
            ex.printStackTrace();
        }
        logger.info("syncSegmentedDataTask运行完成");
@@ -114,15 +115,15 @@
    public List<ElectricityPriceSegmentedDTO> getElectricityPriceSegmentedList(String accessToken){
        logger.info("accessToken: " + accessToken);
        Map<String, String> paramsMap = new HashMap<>();
        LocalDate date = LocalDate.now();  // 获取当前日期的LocalDate实例
        String year = String.valueOf(date.getYear());
        paramsMap.put("clock", year);
        Date now = Date.from(Instant.now());
        paramsMap.put("clock", DateUtils.format(now, "yyyy-MM"));
        paramsMap.put("timeGranId", "MONTH");
        logger.info("请求参数:" + JSON.toJSONString(paramsMap));
        String resp = HttpUtils.sendPost(QUERY_SEGMENTED_DATA_URL, JSON.toJSONString(paramsMap), accessToken);
        String resp = HttpUtils.sendPostToken(QUERY_SEGMENTED_DATA_URL, JSON.toJSONString(paramsMap), accessToken);
        logger.info("获取分段数据的返回值:" + resp);
        JSONObject jsonObject = JSON.parseObject(resp);
        List<ElectricityPriceSegmentedDTO> list = jsonObject.getJSONArray("data").toJavaList(ElectricityPriceSegmentedDTO.class);
        list.forEach(item -> item.setYear(year));
        list.forEach(item -> item.setYear(DateUtils.format(now, "yyyy")));
        return list;
    }
@@ -132,4 +133,5 @@
        cipher.init(Cipher.ENCRYPT_MODE, publicKey);
        return Base64.getEncoder().encodeToString(cipher.doFinal(data.getBytes()));
    }
}