Commit 4c06d7e3 authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.对接第三方接口,接入第三方数据,完成Token接口验证,抽取公用方法封装调用工具类;
2.对接第三方接口,完成获取日耗电日产液等信息接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
3.对接第三方接口,完成获取有功功率数据信息接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
4.对接第三方接口,完成获取甘特图数据接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
5.对接第三方接口,完成本日累计数据接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
6.对接第三方接口,完成光伏发电量接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
7.对接第三方接口,完成三叠登录接口调用,添加线上接口文档并完成接口及定时任务冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 771799bd
...@@ -10,10 +10,15 @@ public class ThirdPartyApiConstant { ...@@ -10,10 +10,15 @@ public class ThirdPartyApiConstant {
/*------------------------------ 长庆 ------------------------------*/ /*------------------------------ 长庆 ------------------------------*/
/** /**
* Redis缓存key * Redis缓存key(长庆)
*/ */
public static final String CQ_TOKEN_CACHE_KEY = "pps.third.cq.token"; public static final String CQ_TOKEN_CACHE_KEY = "pps.third.cq.token";
/**
* Redis缓存key(三叠)
*/
public static final String CQ_TOKEN_SAN_DIE_CACHE_KEY = "pps.third.cq.sd.token";
/** /**
* 过期时间 * 过期时间
*/ */
......
...@@ -12,6 +12,7 @@ public enum BusinessError implements XError { ...@@ -12,6 +12,7 @@ public enum BusinessError implements XError {
DateTypeError(2200, "日期类型错误"), DateTypeError(2200, "日期类型错误"),
TheStartEndDateIsMissing(2201, "缺少开始结束日期"), TheStartEndDateIsMissing(2201, "缺少开始结束日期"),
GetSanDieLoginInfoError(2202, "获取三叠登录信息失败"),
; ;
private int code; private int code;
......
package pps.core.prediction.service; package pps.core.prediction.service;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import pps.core.common.cache.ThirdPartyConfigCache;
import pps.core.prediction.constant.ThirdPartyApiConstant; import pps.core.prediction.constant.ThirdPartyApiConstant;
import pps.core.prediction.enums.BusinessError;
import pps.core.prediction.service.data.third_active_power.GetThirdSanDieLoginInfoOutput; import pps.core.prediction.service.data.third_active_power.GetThirdSanDieLoginInfoOutput;
import xstartup.annotation.XService; import xstartup.annotation.XService;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import xstartup.base.XContext; import xstartup.base.XContext;
import xstartup.base.exception.XServiceException;
import xstartup.base.util.XHttpUtils; import xstartup.base.util.XHttpUtils;
import xstartup.data.XSingleResult; import xstartup.data.XSingleResult;
import xstartup.feature.api.annotation.XApiAnonymous; import xstartup.feature.api.annotation.XApiAnonymous;
...@@ -22,19 +28,55 @@ import xstartup.feature.api.annotation.XApiPost; ...@@ -22,19 +28,55 @@ import xstartup.feature.api.annotation.XApiPost;
@XService @XService
public class ThirdActivePowerService { public class ThirdActivePowerService {
/**
* 获取三叠登录信息
*
* @param context 上下文
* @return {@link XSingleResult}<{@link GetThirdSanDieLoginInfoOutput}>
*/
@XApiAnonymous @XApiAnonymous
@XText("第三方--获取三叠登录信息") @XText("第三方--获取三叠登录信息")
@XApiPost @XApiPost
public XSingleResult<GetThirdSanDieLoginInfoOutput> getThirdSanDieLoginInfo(XContext context) { public XSingleResult<GetThirdSanDieLoginInfoOutput> getThirdSanDieLoginInfo(XContext context) {
String loginInfo;
ThirdPartyConfigCache exist = ThirdPartyConfigCache.exist(context, ThirdPartyApiConstant.CQ_TOKEN_SAN_DIE_CACHE_KEY);
if (ObjectUtil.isNull(exist)) {
loginInfo = this.getSanDieToken(context);
} else {
long duration = (long) exist.getDuration();
if (duration - DateUtil.between(exist.getCurrentDate(), DateUtil.date(), DateUnit.SECOND) < ThirdPartyApiConstant.MAX_SECOND) {
loginInfo = this.getSanDieToken(context);
} else {
loginInfo = exist.getCode();
}
}
return XSingleResult.success(JSON.parseObject(loginInfo, GetThirdSanDieLoginInfoOutput.class));
}
/**
* 获取三叠令牌
*
* @param context 上下文
* @return {@link String}
*/
private String getSanDieToken(XContext context) {
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
param.put("username", "31b5604627e345ebb48175de8f2ee0bdem55ajAwMQ==kj"); param.put("username", "31b5604627e345ebb48175de8f2ee0bdem55ajAwMQ==kj");
param.put("password", "sdSktfem55ajAwMSFAIzEw8ef354f215d44c0eafd403ab7a1ce74a"); param.put("password", "sdSktfem55ajAwMSFAIzEw8ef354f215d44c0eafd403ab7a1ce74a");
String result = XHttpUtils.postAsJson(ThirdPartyApiConstant.CQ_SD_LOGIN, param.toJSONString()); String result = XHttpUtils.postAsJson(ThirdPartyApiConstant.CQ_SD_LOGIN, param.toJSONString());
context.getLogger().info("**** getThirdSanDieLoginInfo result: {}", result); context.getLogger().info("**** getThirdSanDieLoginInfo result: {}", result);
param = JSON.parseObject(result); param = JSON.parseObject(result);
GetThirdSanDieLoginInfoOutput output = JSON.parseObject(param.getString("data"), GetThirdSanDieLoginInfoOutput.class); param = param.getJSONObject("data");
if (param.isEmpty()) {
return XSingleResult.success(output); throw new XServiceException(context, BusinessError.GetSanDieLoginInfoError);
}
String data = param.toJSONString();
ThirdPartyConfigCache cache = new ThirdPartyConfigCache();
cache.setCodeKey(ThirdPartyApiConstant.CQ_TOKEN_SAN_DIE_CACHE_KEY);
cache.setCode(data);
cache.setValidity(240);
cache.setCurrentDate(DateUtil.date());
ThirdPartyConfigCache.set(context, cache);
return data;
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment