Commit 616377a1 authored by ZWT's avatar ZWT

feat(零碳): 长庆演示系统新增功能

1.新建油田配置表同时生成相关代码及mapper文件,修改部分第三方数据抽取定时任务,增加针对不同井场开关控制逻辑,同时修改首页页面展示逻辑,通过油田配置功能区分不同首页展示功能;
2.新建定时任务配置表同时生成相关代码及mapper文件,定时任务模块增加mybatis配置,用以操作数据库,修改部分第三方数据抽取定时任务,修改使用方式使其脱离框架方便动态控制;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 444955a1
...@@ -73,14 +73,17 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService { ...@@ -73,14 +73,17 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
@Override @Override
public XServiceResult weatherDataProcess(XContext context, String oilFieldCode) { public XServiceResult weatherDataProcess(XContext context, String oilFieldCode) {
XLoggerTool logger = context.getLogger(); XLoggerTool logger = context.getLogger();
//取电站(排除第二采油厂)
BasePhotovoltaicPlantViewMapper viewMapper = context.getBean(BasePhotovoltaicPlantViewMapper.class);
List<BasePhotovoltaicPlantView> plantList = viewMapper.selectPlantList(new BasePhotovoltaicPlantView());
if (CollUtil.isEmpty(plantList)) {
logger.info("------ weatherDataProcess plantList is empty ------");
return null;
}
//取未读邮件 //取未读邮件
Store store = null; Store store = null;
Folder folder = null; Folder folder = null;
List<PlantPredictedPowerDataEnt> deleteList = new ArrayList<>(32); List<JSONObject> jsonObjectList = new ArrayList<>();
List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>(13312);
List<String> timeList = Arrays.asList("15:00", "30:00", "45:00");
DateTime create = DateUtil.offsetMinute(DateTime.of(DateUtil.now(), "yyyy-MM-dd HH"), -5);
DateTime end = DateUtil.offsetDay(create, 16);
try { try {
Properties props = new Properties(); Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null); Session session = Session.getDefaultInstance(props, null);
...@@ -91,16 +94,6 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService { ...@@ -91,16 +94,6 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
logger.info("------ weatherDataProcess connect mail ------"); logger.info("------ weatherDataProcess connect mail ------");
List<Message> messageList = ReceivedIMAPMail.filterMessage(folder.getMessages(), null, null); List<Message> messageList = ReceivedIMAPMail.filterMessage(folder.getMessages(), null, null);
if (CollUtil.isNotEmpty(messageList)) { if (CollUtil.isNotEmpty(messageList)) {
//取电站(排除第二采油厂)
BasePhotovoltaicPlantViewMapper viewMapper = context.getBean(BasePhotovoltaicPlantViewMapper.class);
List<BasePhotovoltaicPlantView> plantList = viewMapper.selectPlantList(new BasePhotovoltaicPlantView());
if (CollUtil.isEmpty(plantList)) {
logger.info("------ weatherDataProcess plantList is empty ------");
return null;
}
//按照cityCode分组
Map<String, List<BasePhotovoltaicPlantView>> plantMap = plantList.stream()
.collect(Collectors.groupingBy(BasePhotovoltaicPlantView::getCityCode));
for (Message message : messageList) { for (Message message : messageList) {
ReceivedIMAPMail re = new ReceivedIMAPMail((MimeMessage) message); ReceivedIMAPMail re = new ReceivedIMAPMail((MimeMessage) message);
String subject = re.getSubject(); String subject = re.getSubject();
...@@ -115,6 +108,59 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService { ...@@ -115,6 +108,59 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
FileReader fileReader = new FileReader(tempFilePath); FileReader fileReader = new FileReader(tempFilePath);
String jsonString = fileReader.readString(); String jsonString = fileReader.readString();
JSONObject jsonObject = JSON.parseObject(jsonString); JSONObject jsonObject = JSON.parseObject(jsonString);
jsonObjectList.add(jsonObject);
logger.info("------ weatherDataProcess del temp file path: {}", tempFilePath);
FileUtil.del(tempFilePath);
message.setFlag(Flags.Flag.DELETED, true);
}
}
} catch (MessagingException e) {
logger.error("------ weatherDataProcess MessagingException", e);
} catch (IOException e) {
logger.error("------ weatherDataProcess IOException", e);
} catch (ParseException e) {
logger.error("------ weatherDataProcess ParseException", e);
} finally {
logger.info("------ weatherDataProcess mail finally close");
NioUtil.close(folder);
NioUtil.close(store);
}
if (CollUtil.isNotEmpty(jsonObjectList)) {
logger.info("------ weatherDataProcess dataFractionation");
List<PlantPredictedPowerDataEnt> deleteList = new ArrayList<>(32);
List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>(13312);
List<String> timeList = Arrays.asList("15:00", "30:00", "45:00");
DateTime create = DateUtil.offsetMinute(DateTime.of(DateUtil.now(), "yyyy-MM-dd HH"), -5);
DateTime end = DateUtil.offsetDay(create, 16);
//按照cityCode分组
Map<String, List<BasePhotovoltaicPlantView>> plantMap = plantList.stream()
.collect(Collectors.groupingBy(BasePhotovoltaicPlantView::getCityCode));
for (JSONObject jsonObject : jsonObjectList) {
this.dataFractionation(jsonObject, plantMap, deleteList, create, end, batchList, timeList);
}
logger.info("------ weatherDataProcess delete and insertBatch");
XThreadHelper.async(() -> {
this.deletePlantPredictedPowerList(context, deleteList);
this.insertBatchPlantPredictedPowerList(context, batchList);
logger.info("------ weatherDataProcess delete and insertBatch finish");
});
}
return XServiceResult.OK;
}
/**
* 数据拆分
*
* @param jsonObject json对象
* @param plantMap 植物地图
* @param deleteList 删除列表
* @param create 创造
* @param end 结束
* @param batchList 批次列表
* @param timeList 时间表
*/
private void dataFractionation(JSONObject jsonObject, Map<String, List<BasePhotovoltaicPlantView>> plantMap, List<PlantPredictedPowerDataEnt> deleteList,
DateTime create, DateTime end, List<PlantPredictedPowerDataEnt> batchList, List<String> timeList) {
Map<String, List<DailyData>> cityDataMap = new HashMap<>(16); Map<String, List<DailyData>> cityDataMap = new HashMap<>(16);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) { for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
...@@ -263,31 +309,9 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService { ...@@ -263,31 +309,9 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
} }
} }
} }
logger.info("------ weatherDataProcess del temp file path: {}", tempFilePath);
FileUtil.del(tempFilePath);
message.setFlag(Flags.Flag.DELETED, true);
}
}
} catch (MessagingException e) {
logger.error("------ weatherDataProcess MessagingException", e);
} catch (IOException e) {
logger.error("------ weatherDataProcess IOException", e);
} catch (ParseException e) {
logger.error("------ weatherDataProcess ParseException", e);
} finally {
logger.info("------ weatherDataProcess finally close");
NioUtil.close(folder);
NioUtil.close(store);
}
logger.info("------ weatherDataProcess delete and insertBatch");
XThreadHelper.async(() -> {
this.deletePlantPredictedPowerList(context, deleteList);
this.insertBatchPlantPredictedPowerList(context, batchList);
logger.info("------ weatherDataProcess delete and insertBatch finish");
});
return XServiceResult.OK;
} }
/** /**
* 天气数据接收Cloud模块--天气Api数据处理 * 天气数据接收Cloud模块--天气Api数据处理
* *
......
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