Commit 7609abb5 authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.长庆演示首页功能开发,新增采油厂统计信息查询接口,添加线上接口并完成接口冒烟测试;
2.长庆演示首页功能开发,新增线路图查询接口,添加线上接口并完成接口冒烟测试;
3.长庆演示首页功能开发,新增线路详情查询接口,添加线上接口并完成接口冒烟测试;
4.对接第三方接口,完成获取井场日累计数据接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;
5.对接第三方接口,完成获取第三方单井平均有功功率接口调用,创建数据表,同时生成对应代码,开发定时任务及对外接口,完成第三方数据接入及系统展示功能,添加线上接口文档并完成接口及定时任务冒烟测试;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent a074073d
package pps.core.task.job;
import cn.hutool.core.util.ObjectUtil;
import pps.cloud.prediction.service.IThirdDataAccessCloudService;
import pps.core.common.cache.TaskLockCache;
import pps.core.task.constant.TaskConstant;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
......@@ -27,7 +30,25 @@ public class ThirdWellAvgActivePowerJob implements XJob {
@XCronTrigger(value = TaskConstant.HOUR_ZERO)
@Override
public XServiceResult execute(XContext xContext) {
return null;
xContext.getLogger().info("------ ThirdWellAvgActivePowerJob start:{}", System.currentTimeMillis());
String key = TaskConstant.TASK_LOCK_KEY + "ThirdWellAvgActivePowerJob";
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 {
IThirdDataAccessCloudService service = xContext.getBean(IThirdDataAccessCloudService.class);
XServiceResult result = service.thirdWellAvgActivePowerJob(xContext);
result.throwIfFail();
} catch (Exception e) {
xContext.getLogger().error("------ ThirdWellAvgActivePowerJob Exception: ", e);
} finally {
xContext.getLogger().info("------ ThirdWellAvgActivePowerJob end:{}", System.currentTimeMillis());
TaskLockCache.delete(xContext, key);
}
}
return XServiceResult.OK;
}
}
......@@ -59,4 +59,13 @@ public interface IThirdDataAccessCloudService {
*/
@XText("第三方井场日累计数据定时任务")
XServiceResult thirdDailyAccumulationJob(XContext context);
/**
* 第三方单井平均有功功率定时任务
*
* @param context 上下文
* @return {@link XServiceResult}
*/
@XText("第三方单井平均有功功率定时任务")
XServiceResult thirdWellAvgActivePowerJob(XContext context);
}
package pps.core.prediction.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import xstartup.annotation.XText;
import java.io.Serializable;
......@@ -15,6 +18,9 @@ import java.util.Date;
* @date 2024/04/01
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class ThirdWellAvgActivePowerView implements Serializable {
@XText("ID")
@TableField
......
package pps.core.prediction.mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import pps.core.prediction.entity.ThirdWellAvgActivePowerView;
......@@ -16,4 +17,13 @@ public interface ThirdWellAvgActivePowerViewMapper {
ThirdWellAvgActivePowerView selectOne(ThirdWellAvgActivePowerView record);
List<ThirdWellAvgActivePowerView> selectList(ThirdWellAvgActivePowerView record);
/**
* 批量插入
*
* @param dtoList dto列表
* @return int
*/
int batchInsertList(@Param(value = "list") List<ThirdWellAvgActivePowerView> dtoList);
}
......@@ -19,6 +19,7 @@ import pps.core.prediction.service.data.third_active_power.GetThirdActivePowerVi
import pps.core.prediction.service.data.third_current_well_condition.GetThirdCurrentWellConditionViewOutput;
import pps.core.prediction.service.data.third_daily_accumulation.GetCumulativePowerGenerationOutput;
import pps.core.prediction.service.data.third_photovoltaic_power.GetThirdPhotovoltaicPowerViewOutput;
import pps.core.prediction.service.data.third_well_avg_active_power.GetThirdWellAvgActivePowerOutput;
import pps.core.prediction.utils.ServiceUtil;
import xstartup.annotation.XService;
import xstartup.annotation.XText;
......@@ -267,7 +268,7 @@ public class ThirdDataAccessCloudServiceImpl implements IThirdDataAccessCloudSer
DateTime beginOfDay = DateUtil.beginOfDay(now);
//封装数据
List<ThirdDailyAccumulationView> dtoList = new ArrayList<>(outputs.size());
LambdaQueryWrapper<ThirdDailyAccumulationEnt> queryWrapper = new LambdaQueryWrapper<ThirdDailyAccumulationEnt>();
LambdaQueryWrapper<ThirdDailyAccumulationEnt> queryWrapper = new LambdaQueryWrapper<>();
for (GetCumulativePowerGenerationOutput o : outputs) {
dtoList.add(
ThirdDailyAccumulationView.builder()
......@@ -292,8 +293,57 @@ public class ThirdDataAccessCloudServiceImpl implements IThirdDataAccessCloudSer
//先删除
ThirdDailyAccumulationMapper bean = context.getBean(ThirdDailyAccumulationMapper.class);
bean.delete(queryWrapper);
//保存当日最新数据
ThirdDailyAccumulationViewMapper mapper = context.getBean(ThirdDailyAccumulationViewMapper.class);
mapper.batchInsertList(dtoList);
return XServiceResult.OK;
});
}
/**
* 第三井平均有功功率作业
*
* @param context 上下文
* @return {@link XServiceResult}
*/
@Override
public XServiceResult thirdWellAvgActivePowerJob(XContext context) {
String resultStr = ServiceUtil.doPostFormCq(context,
ThirdPartyApiConstant.CQ_AVG_ACTIVE_POWER,
new HashMap<>(0));
context.getLogger().info("*** CQ_AVG_ACTIVE_POWER : {}", resultStr);
List<GetThirdWellAvgActivePowerOutput> outputs = JSON.parseArray(resultStr, GetThirdWellAvgActivePowerOutput.class);
if (CollUtil.isEmpty(outputs)) {
return XServiceResult.OK;
}
DateTime beginOfDay = DateUtil.date();
//封装数据
List<ThirdWellAvgActivePowerView> dtoList = new ArrayList<>(outputs.size());
LambdaQueryWrapper<ThirdWellAvgActivePowerEnt> queryWrapper = new LambdaQueryWrapper<>();
for (GetThirdWellAvgActivePowerOutput o : outputs) {
dtoList.add(
ThirdWellAvgActivePowerView.builder()
.saveDate(beginOfDay)
.wellNumber(o.getWellNumber())
.inputTime(o.getInputTime())
.avgActivePower(o.getAvgActivePower())
.systemSource(ThirdPartyApiConstant.CQ_SOURCE)
.saveDate(beginOfDay)
.build()
);
//组装删除条件
queryWrapper.or(w -> w.eq(ThirdWellAvgActivePowerEnt::getWellNumber, o.getWellNumber())
.eq(ThirdWellAvgActivePowerEnt::getInputTime, o.getInputTime())
.eq(ThirdWellAvgActivePowerEnt::getAvgActivePower, o.getAvgActivePower())
.eq(ThirdWellAvgActivePowerEnt::getSystemSource, ThirdPartyApiConstant.CQ_SOURCE)
);
}
return XTransactionHelper.begin(context, () -> {
//先删除
ThirdWellAvgActivePowerMapper bean = context.getBean(ThirdWellAvgActivePowerMapper.class);
bean.delete(queryWrapper);
//保存当日最新数据
ThirdWellAvgActivePowerViewMapper mapper = context.getBean(ThirdWellAvgActivePowerViewMapper.class);
mapper.batchInsertList(dtoList);
return XServiceResult.OK;
});
......
......@@ -34,4 +34,19 @@
where
id=#{id}
</select>
<insert id="batchInsertList" parameterType="list">
INSERT INTO third_well_avg_active_power ( well_number, input_time, avg_active_power, system_source,
save_date )
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.wellNumber},
#{item.inputTime},
#{item.avgActivePower},
#{item.systemSource},
#{item.saveDate}
)
</foreach>
</insert>
</mapper>
\ No newline at end of file
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