Commit 66b5aa86 authored by ZWT's avatar ZWT

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

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

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent b9cf43ef
......@@ -18,4 +18,11 @@ public interface BasePhotovoltaicPlantViewMapper {
List<BasePhotovoltaicPlantView> selectList(BasePhotovoltaicPlantView record);
List<BasePhotovoltaicPlantView> selectPlantDetailList(BasePhotovoltaicPlantView record);
/**
* 获得所有可用的电站
*
* @return {@link List}<{@link BasePhotovoltaicPlantView}>
*/
List<BasePhotovoltaicPlantView> selectPlantList();
}
......@@ -12,6 +12,8 @@ import com.alibaba.fastjson.JSONObject;
import com.sun.mail.imap.IMAPFolder;
import org.apache.commons.lang3.StringUtils;
import pps.cloud.base.service.IBaseWeatherCloudService;
import pps.core.base.entity.BasePhotovoltaicPlantView;
import pps.core.base.mapper.BasePhotovoltaicPlantViewMapper;
import pps.core.base.service.data.DailyData;
import xstartup.annotation.XService;
import xstartup.base.XContext;
......@@ -24,6 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.stream.Collectors;
/**
* 天气数据接收Cloud模块
......@@ -83,24 +86,35 @@ public class BaseWeatherCloudServiceImpl implements IBaseWeatherCloudService {
messageList.add(message);
}
}
if (CollUtil.isNotEmpty(messageList)) {
//读取附件
for (Message message : messageList) {
String tempFilePath = this.saveAttachment(message);
FileReader fileReader = new FileReader(tempFilePath);
String jsonString = fileReader.readString();
JSONObject jsonObject = JSONObject.parseObject(jsonString);
Map<String, List<DailyData>> cityDataMap = new HashMap<>(16);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof JSONArray) {
cityDataMap.put(key, ((JSONArray) value).toJavaList(DailyData.class));
}
if (CollUtil.isEmpty(messageList)) {
return null;
}
//取电站
BasePhotovoltaicPlantViewMapper mapper = context.getBean(BasePhotovoltaicPlantViewMapper.class);
List<BasePhotovoltaicPlantView> plantList = mapper.selectPlantList();
if (CollUtil.isEmpty(plantList)) {
return null;
}
//按照cityCode分组
Map<String, List<BasePhotovoltaicPlantView>> collect = plantList.stream()
.collect(Collectors.groupingBy(BasePhotovoltaicPlantView::getCityCode));
//读取附件
for (Message message : messageList) {
String tempFilePath = this.saveAttachment(message);
FileReader fileReader = new FileReader(tempFilePath);
String jsonString = fileReader.readString();
JSONObject jsonObject = JSONObject.parseObject(jsonString);
Map<String, List<DailyData>> cityDataMap = new HashMap<>(16);
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof JSONArray) {
cityDataMap.put(key, ((JSONArray) value).toJavaList(DailyData.class));
}
FileUtil.del(tempFilePath);
}
FileUtil.del(tempFilePath);
}
}
} catch (MessagingException e) {
......
......@@ -90,4 +90,31 @@
left join sys_area sa on sa.id = so.province
where p.is_deleted = #{isDeleted}
</select>
<select id="selectPlantList" resultMap="BaseResultMap">
SELECT p.id,
p.is_deleted,
p.create_by_id,
p.create_by_name,
p.create_time,
p.modify_by_id,
p.modify_by_name,
p.modify_time,
p.ou_id,
p.ou_name,
p.station_name,
p.maker_number,
p.photovoltaic_model_key,
p.photovoltaic_model_name,
p.mounting_angle,
p.total_power,
p.array_orientation,
p.area_code,
a.city_code
FROM base_photovoltaic_plant p
LEFT JOIN sys_area a ON a.id = p.area_code
WHERE p.is_deleted = 1
AND p.area_code IS NOT NULL
ORDER BY modify_time DESC
</select>
</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