Commit c538741f authored by ZWT's avatar ZWT

nocommit

parent 1fcea70a
...@@ -23,6 +23,11 @@ public class TaskConstant { ...@@ -23,6 +23,11 @@ public class TaskConstant {
*/ */
public static final String EVERY_DAY = "0 15 0 * * ?"; public static final String EVERY_DAY = "0 15 0 * * ?";
/**
* 每一天 00:00:00
*/
public static final String EVERY_DAY_ZERO = "0 0 0 * * ?";
/** /**
* 每一天结束时间 23:50:00 * 每一天结束时间 23:50:00
*/ */
......
package pps.core.task.job;
import cn.hutool.core.util.ObjectUtil;
import pps.cloud.prediction.service.IPlantPredictedPowerCloudService;
import pps.core.common.cache.TaskLockCache;
import pps.core.task.constant.TaskConstant;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
import xstartup.base.XContext;
import xstartup.data.XServiceResult;
import xstartup.service.job.XJob;
import xstartup.service.job.annotation.XCronTrigger;
/**
* 日耗电日产液信息
*
* @author ZWT
* @date 2024/03/18 14:52
*/
@XText("日耗电日产液信息定时任务")
@XService
public class WellTechDailyJob implements XJob {
/**
* 每天0点执行
*
* @param xContext x上下文
* @return {@link XServiceResult}
*/
@XCronTrigger(value = TaskConstant.EVERY_DAY_ZERO)
@Override
public XServiceResult execute(XContext xContext) {
xContext.getLogger().info("------ WellTechDailyJob start:{}", System.currentTimeMillis());
String key = TaskConstant.TASK_LOCK_KEY + "WellTechDailyJob";
TaskLockCache exist = TaskLockCache.exist(xContext, key);
if (ObjectUtil.isNull(exist)) {
TaskLockCache cache = new TaskLockCache();
cache.setRedisKey(key);
cache.setRedisValue(key);
TaskLockCache.set(xContext, cache);
try {
IPlantPredictedPowerCloudService service = xContext.getBean(IPlantPredictedPowerCloudService.class);
XServiceResult result = service.wellTechDailyJob(xContext);
result.throwIfFail();
} catch (Exception e) {
xContext.getLogger().error("------ WellTechDailyJob Exception: ", e);
} finally {
xContext.getLogger().info("------ WellTechDailyJob end:{}", System.currentTimeMillis());
TaskLockCache.delete(xContext, key);
}
}
return XServiceResult.OK;
}
}
...@@ -6,7 +6,7 @@ import xstartup.annotation.XService; ...@@ -6,7 +6,7 @@ import xstartup.annotation.XService;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import xstartup.base.XContext; import xstartup.base.XContext;
import xstartup.data.XListResult; import xstartup.data.XListResult;
import xstartup.feature.api.annotation.XApiPost; import xstartup.data.XServiceResult;
/** /**
* 光伏预测Cloud模块 * 光伏预测Cloud模块
...@@ -26,7 +26,6 @@ public interface IPlantPredictedPowerCloudService { ...@@ -26,7 +26,6 @@ public interface IPlantPredictedPowerCloudService {
* @return {@link XListResult}<{@link DynamicQueryPlantPredictedPowerOutput}> * @return {@link XListResult}<{@link DynamicQueryPlantPredictedPowerOutput}>
*/ */
@XText("光伏预测Cloud模块--条件查询时段发电量平均值") @XText("光伏预测Cloud模块--条件查询时段发电量平均值")
@XApiPost
XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input); XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input);
/** /**
...@@ -37,6 +36,14 @@ public interface IPlantPredictedPowerCloudService { ...@@ -37,6 +36,14 @@ public interface IPlantPredictedPowerCloudService {
* @return {@link XListResult}<{@link DynamicQueryPlantPredictedPowerOutput}> * @return {@link XListResult}<{@link DynamicQueryPlantPredictedPowerOutput}>
*/ */
@XText("光伏预测Cloud模块--获取每小时平均发电量列表") @XText("光伏预测Cloud模块--获取每小时平均发电量列表")
@XApiPost
XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationHourListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input); XListResult<DynamicQueryPlantPredictedPowerOutput> queryAveragePowerGenerationHourListByParam(XContext context, DynamicQueryPlantPredictedPowerInput input);
/**
* 日耗电日产液信息定时任务
*
* @param context 上下文
* @return {@link XServiceResult}
*/
@XText("光伏预测Cloud模块--日耗电日产液信息定时任务")
XServiceResult wellTechDailyJob(XContext context);
} }
\ No newline at end of file
package pps.core.prediction.service; package pps.core.prediction.service;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import pps.cloud.prediction.service.IPlantPredictedPowerCloudService; import pps.cloud.prediction.service.IPlantPredictedPowerCloudService;
import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerInput; import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerInput;
import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerOutput; import pps.cloud.prediction.service.data.plant_predicted_power_data.DynamicQueryPlantPredictedPowerOutput;
import pps.core.auth.HttpRequestClient;
import pps.core.prediction.constant.ThirdPartyApiConstant;
import pps.core.prediction.entity.PlantPredictedPowerDataEnt; import pps.core.prediction.entity.PlantPredictedPowerDataEnt;
import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt; import pps.core.prediction.entity.PlantPredictedPowerLongTermDataEnt;
import pps.core.prediction.mapper.PlantPredictedPowerDataMapper; import pps.core.prediction.mapper.PlantPredictedPowerDataMapper;
import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper; import pps.core.prediction.mapper.PlantPredictedPowerLongTermDataMapper;
import pps.core.prediction.utils.ServiceUtil;
import xstartup.annotation.XService; import xstartup.annotation.XService;
import xstartup.base.XContext; import xstartup.base.XContext;
import xstartup.base.XStartup;
import xstartup.base.util.XCopyUtils; import xstartup.base.util.XCopyUtils;
import xstartup.data.XListResult; import xstartup.data.XListResult;
import xstartup.data.XServiceResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 光伏预测Cloud模块 * 光伏预测Cloud模块
...@@ -158,4 +166,22 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower ...@@ -158,4 +166,22 @@ public class PlantPredictedPowerCloudServiceImpl implements IPlantPredictedPower
} }
return XListResult.success(outputs); return XListResult.success(outputs);
} }
/**
* 日耗电日产液信息定时任务
*
* @param context 上下文
* @return {@link XServiceResult}
*/
@Override
public XServiceResult wellTechDailyJob(XContext context) {
String token = ServiceUtil.getToken(context);
HttpRequestClient client = new HttpRequestClient(token);
String url = XStartup.getCurrent().getProperty("third-party.chang-qing.url");
String api = url + ThirdPartyApiConstant.CQ_WELL_TECH_DAILY;
Map<String, Object> param = new HashMap<>(2);
param.put("Calc_Date", DateUtil.date().toString("yyyy-MM-dd"));
String s = client.doPostForm(api, param);
return XServiceResult.OK;
}
} }
...@@ -22,7 +22,6 @@ import xstartup.base.XContext; ...@@ -22,7 +22,6 @@ import xstartup.base.XContext;
import xstartup.base.XStartup; import xstartup.base.XStartup;
import xstartup.base.util.XCopyUtils; import xstartup.base.util.XCopyUtils;
import xstartup.base.util.XHttpUtils; import xstartup.base.util.XHttpUtils;
import xstartup.data.XListResult;
import xstartup.data.XPageResult; import xstartup.data.XPageResult;
import xstartup.data.XServiceResult; import xstartup.data.XServiceResult;
import xstartup.feature.api.annotation.XApiAnonymous; import xstartup.feature.api.annotation.XApiAnonymous;
...@@ -74,14 +73,6 @@ public class WellheadDailyProductionSituationService { ...@@ -74,14 +73,6 @@ public class WellheadDailyProductionSituationService {
return XPageResult.success(outputs, input, pageInfo.getTotal()); return XPageResult.success(outputs, input, pageInfo.getTotal());
} }
@XText("井口生产情况--t")
@XApiAnonymous
@XApiPost
public XListResult<QueryWellheadDailyProductionSituationOutput> t(XContext context, QueryWellheadDailyProductionSituationInput input) {
String cqToken = this.getToken(context);
return XListResult.success();
}
@XApiAnonymous @XApiAnonymous
@XText("井口生产情况--test") @XText("井口生产情况--test")
@XApiGet @XApiGet
......
package pps.core.prediction.utils;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import pps.core.common.cache.ThirdPartyConfigCache;
import pps.core.prediction.constant.ThirdPartyApiConstant;
import xstartup.base.XContext;
import xstartup.base.XStartup;
import xstartup.base.util.XHttpUtils;
import java.util.HashMap;
import java.util.Map;
/**
* 常用服务调用工具类
*
* @author ZWT
* @date 2024/03/18 15:07
*/
public class ServiceUtil {
/**
* 获取长庆TOKEN
*
* @param context 上下文
* @return {@link String}
*/
public static String getToken(XContext context) {
String token;
ThirdPartyConfigCache exist = ThirdPartyConfigCache.exist(context, ThirdPartyApiConstant.CQ_TOKEN_CACHE_KEY);
if (ObjectUtil.isNull(exist)) {
token = ServiceUtil.getCqToken(context);
} else {
long duration = (long) exist.getDuration();
if (duration - DateUtil.between(exist.getCurrentDate(), DateUtil.date(), DateUnit.SECOND) < ThirdPartyApiConstant.MAX_SECOND) {
token = ServiceUtil.getCqToken(context);
} else {
token = exist.getCode();
}
}
return token;
}
/*----------------------------------- 私有方法 -----------------------------------*/
/**
* 获取长庆Token
*
* @return {@link String}
*/
private static String getCqToken(XContext context) {
String url = XStartup.getCurrent().getProperty("third-party.chang-qing.url");
url += ThirdPartyApiConstant.CQ_TOKEN;
Map<String, String> param = new HashMap<>(4);
param.put("UserAccount", "PvGroup");
param.put("UserPassWord", "PvGroup@147369");
String result = XHttpUtils.postAsForm(url, param);
JSONObject jsonObject = JSONUtil.parseObj(result);
String token = jsonObject.getStr("token");
ServiceUtil.setThirdPartyConfigCache(context, token);
return token;
}
/**
* 设置缓存
*
* @param context 上下文
* @param token 代币
*/
private static void setThirdPartyConfigCache(XContext context, String token) {
ThirdPartyConfigCache cache = new ThirdPartyConfigCache();
cache.setCodeKey(ThirdPartyApiConstant.CQ_TOKEN_CACHE_KEY);
cache.setCode(token);
cache.setValidity(90);
cache.setCurrentDate(DateUtil.date());
ThirdPartyConfigCache.set(context, cache);
}
}
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