Commit 61ae630f authored by ZWT's avatar ZWT

feat(能源管理系统): 邮件接收

1.添加天气数据邮件方式接收定时任务;
2.修改配置文件,增加新建定时任务,同时增加自定义参数;
3.创建天气邮件数据接收处理实现类,同时验证获取自定义参数方法;
4.添加收件工具类,验证是否能正常接收邮件;
5.天气邮件数据接收定时任务增加获取未读天气数据逻辑,增加附件文件临时存储方法并验证是否能正常读取文件数据同时转换为json数据;
6.增加查询运行中电站列表方法;
7.增加数据插入方法并进行结果验证;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 974c6960
......@@ -31,7 +31,9 @@ import xstartup.annotation.XService;
import xstartup.base.XContext;
import xstartup.base.XStartup;
import xstartup.base.exception.XServiceException;
import xstartup.base.tool.XLoggerTool;
import xstartup.base.util.XCopyUtils;
import xstartup.core.base.helper.XThreadHelper;
import xstartup.data.XServiceResult;
import xstartup.helper.XTransactionHelper;
......@@ -62,6 +64,7 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
*/
@Override
public XServiceResult weatherDataProcess(XContext context) {
XLoggerTool logger = context.getLogger();
String host = XStartup.getCurrent().getProperty("weather.mail.host");
String username = XStartup.getCurrent().getProperty("weather.mail.username");
String password = XStartup.getCurrent().getProperty("weather.mail.password");
......@@ -90,6 +93,7 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
if (Objects.nonNull(folder)) {
folder.open(Folder.READ_WRITE);
}
logger.info("------ weatherDataProcess connect mail ------");
Message[] messages = folder.getMessages();
if (ArrayUtil.isNotEmpty(messages)) {
List<Message> messageList = new ArrayList<>(16);
......@@ -105,12 +109,14 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
}
}
if (CollUtil.isEmpty(messageList)) {
logger.info("------ weatherDataProcess messageList is empty ------");
return null;
}
//取电站
BasePhotovoltaicPlantViewMapper viewMapper = context.getBean(BasePhotovoltaicPlantViewMapper.class);
List<BasePhotovoltaicPlantView> plantList = viewMapper.selectPlantList();
if (CollUtil.isEmpty(plantList)) {
logger.info("------ weatherDataProcess plantList is empty ------");
return null;
}
//按照cityCode分组
......@@ -122,6 +128,7 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
//读取附件
for (Message message : messageList) {
String tempFilePath = this.saveAttachment(message);
logger.info("------ weatherDataProcess load file: {}", tempFilePath);
FileReader fileReader = new FileReader(tempFilePath);
String jsonString = fileReader.readString();
JSONObject jsonObject = JSON.parseObject(jsonString);
......@@ -270,6 +277,7 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
}
if (CollUtil.isNotEmpty(batchList)) {
int size = batchList.size();
logger.info("------ weatherDataProcess batchList insert plantId: {} size: {}", plantId, size);
if (size > BaseUtils.BATCH_SIZE) {
List<List<PlantPredictedPowerDataEnt>> subList = BaseUtils.getSubList(batchList);
subList.forEach(dataViewMapper::insertBatch);
......@@ -279,18 +287,27 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
}
//训练接口http://127.0.0.1:10098/aiprediction/xgbtrain?plantId=018a64635ac47cf58895147b0e1bf7e3
//自动调用预测接口
XThreadHelper.async(() -> {
try {
logger.info("------ weatherDataProcess http prediction plantId: {} ", plantId);
HttpUtils.send2("http://127.0.0.1:10098/aiprediction/xgbreason?plantId=" + plantId, "");
} catch (Exception e) {
logger.error("------ weatherDataProcess Exception", e);
throw new XServiceException(e);
}
});
}
}
}
logger.info("------ weatherDataProcess del temp file path: {}", tempFilePath);
FileUtil.del(tempFilePath);
}
}
} catch (MessagingException e) {
logger.error("------ weatherDataProcess MessagingException", e);
throw new XServiceException(e);
} catch (IOException e) {
throw new XServiceException(e);
} catch (Exception e) {
logger.error("------ weatherDataProcess IOException", e);
throw new XServiceException(e);
} finally {
NioUtil.close(folder);
......
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