Commit 8e865672 authored by ZWT's avatar ZWT

feat(零碳): 长庆

1.修改极短期间开预测定时任务逻辑,解决优化后部分优化结果时间段过短问题;
2.修改心知天气气象数据获取及接收定时任务,解决天气数据通过邮件下载后,部分数据精度丢失问题;
3.修改首页各个接口逻辑,对小数类型字段进行处理,修改首页接口,增加小时保留两位四舍五入逻辑,同时解决线路详情接口部分查询逻辑报错问题;
4.能耗分析模块,能耗概览接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;
5.能耗分析模块,消纳曲线用电趋势接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;
6.能耗分析模块,用电详情接口修改,修改查询逻辑,修改数据获取逻辑及绿电占比计算逻辑;
7.修改首页先导实验井间开制度模块接口查询逻辑,解决极短期间开优化修改后没有第一次开井时间标识导致数据查询不出来问题;
8.基础间开制度新增修改接口逻辑修改,删除防冻堵对井口处理逻辑;
9.极短期间开优化算法修改,增加防冻堵井开井时间优化逻辑;
10.提供长庆通过日期获取当日间开优化结果接口开发,完成接口冒烟测试并添加线上接口文档;
11.提供长庆1天光伏出力预测结果接口开发,完成接口冒烟测试并添加线上接口文档;
12.提供长庆15天光伏出力预测结果接口开发,完成接口冒烟测试并添加线上接口文档;
13.修改极短期间开优化算法,优化防冻堵策略;
14.开发第三方历史天气导入功能;

BREAKING CHANGE: 无

Closes 无

[skip ci]
parent 615c731c
...@@ -120,7 +120,6 @@ public class BaseDataService { ...@@ -120,7 +120,6 @@ public class BaseDataService {
queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime); queryWrapper.lambda().ge(BaseDataEnt::getDataDate, beginTime);
queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime); queryWrapper.lambda().le(BaseDataEnt::getDataDate, endTime);
} }
} }
queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId()); queryWrapper.lambda().eq(BaseDataEnt::getLineId, input.getLineId());
queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate); queryWrapper.lambda().orderByAsc(BaseDataEnt::getDataDate);
...@@ -217,7 +216,6 @@ public class BaseDataService { ...@@ -217,7 +216,6 @@ public class BaseDataService {
return XMapperHelper.query(mapper, input, BaseDataEnt.class, QueryBaseDataOutput.class); return XMapperHelper.query(mapper, input, BaseDataEnt.class, QueryBaseDataOutput.class);
} }
@XText("下载导入模板") @XText("下载导入模板")
@XApiGet @XApiGet
public XFileResult downloadImportTemplate(XContext context) { public XFileResult downloadImportTemplate(XContext context) {
...@@ -239,7 +237,6 @@ public class BaseDataService { ...@@ -239,7 +237,6 @@ public class BaseDataService {
List<String> headerList = getExcelHeaderList(); List<String> headerList = getExcelHeaderList();
List<BaseDataView> list = new ArrayList<>(); List<BaseDataView> list = new ArrayList<>();
List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0); List<Map<String, Object>> mapList = ExcelUtils.readExcel(input.getFile().getInputStream(), input.getFile().getFileName(), headerList, 0);
try { try {
List<BaseDataView> dataList = new ArrayList<>(); List<BaseDataView> dataList = new ArrayList<>();
Date minDate = null; Date minDate = null;
...@@ -395,7 +392,6 @@ public class BaseDataService { ...@@ -395,7 +392,6 @@ public class BaseDataService {
} else { } else {
output = new TrainBaseModelValOutput(); output = new TrainBaseModelValOutput();
} }
return XSingleResult.success(output); return XSingleResult.success(output);
} }
} }
\ No newline at end of file
...@@ -80,7 +80,6 @@ public class BaseLineService { ...@@ -80,7 +80,6 @@ public class BaseLineService {
return XServiceResult.OK; return XServiceResult.OK;
} }
public void saveHistory(XContext context, List<ThirdApiWeatherExcelData> cachedDataList) { public void saveHistory(XContext context, List<ThirdApiWeatherExcelData> cachedDataList) {
DateTime date = DateUtil.date(); DateTime date = DateUtil.date();
//查第二采油厂所有电站 //查第二采油厂所有电站
......
...@@ -82,12 +82,7 @@ public class BaseProjectInfoService { ...@@ -82,12 +82,7 @@ public class BaseProjectInfoService {
rateMapper.batchInsert(list); rateMapper.batchInsert(list);
} }
//开始预测 //开始预测
XThreadHelper.async(new Runnable() { XThreadHelper.async(() -> predictedData(context, entity, list));
@Override
public void run() {
predictedData(context, entity, list);
}
});
return XServiceResult.OK; return XServiceResult.OK;
} }
...@@ -129,12 +124,7 @@ public class BaseProjectInfoService { ...@@ -129,12 +124,7 @@ public class BaseProjectInfoService {
rateViewMapper.batchInsert(list); rateViewMapper.batchInsert(list);
} }
//开始预测 //开始预测
XThreadHelper.async(new Runnable() { XThreadHelper.async(() -> predictedData(context, entity, list));
@Override
public void run() {
predictedData(context, entity, list);
}
});
return XServiceResult.OK; return XServiceResult.OK;
} }
...@@ -256,7 +246,7 @@ public class BaseProjectInfoService { ...@@ -256,7 +246,7 @@ public class BaseProjectInfoService {
} }
public Map<String, Object> getPredictedData(XContext context, CalcProjectInfoPredictedDataInput calcProjectInfoPredictedDataInput) { public Map<String, Object> getPredictedData(XContext context, CalcProjectInfoPredictedDataInput calcProjectInfoPredictedDataInput) {
Map<String, Object> returnMap = new HashMap<>(); Map<String, Object> returnMap;
try { try {
String jsonString = XJsonUtils.toJson(calcProjectInfoPredictedDataInput); String jsonString = XJsonUtils.toJson(calcProjectInfoPredictedDataInput);
context.getLogger().info(jsonString); context.getLogger().info(jsonString);
......
...@@ -186,4 +186,4 @@ public class BaseStationOuRelService { ...@@ -186,4 +186,4 @@ public class BaseStationOuRelService {
} }
return ""; return "";
} }
} }
\ No newline at end of file
...@@ -8,7 +8,6 @@ import pps.core.base.entity.BaseSysConfigView; ...@@ -8,7 +8,6 @@ import pps.core.base.entity.BaseSysConfigView;
import pps.core.base.mapper.BaseSysConfigMapper; import pps.core.base.mapper.BaseSysConfigMapper;
import pps.core.base.mapper.BaseSysConfigViewMapper; import pps.core.base.mapper.BaseSysConfigViewMapper;
import pps.core.base.service.data.base_sys_config.*; import pps.core.base.service.data.base_sys_config.*;
import pps.core.common.session.PpsUserSession;
import xstartup.annotation.XService; import xstartup.annotation.XService;
import xstartup.annotation.XText; import xstartup.annotation.XText;
import xstartup.base.XContext; import xstartup.base.XContext;
...@@ -36,7 +35,6 @@ public class BaseSysConfigService { ...@@ -36,7 +35,6 @@ public class BaseSysConfigService {
BaseSysConfigMapper mapper = context.getBean(BaseSysConfigMapper.class); BaseSysConfigMapper mapper = context.getBean(BaseSysConfigMapper.class);
BaseSysConfigEnt entity = new BaseSysConfigEnt(); BaseSysConfigEnt entity = new BaseSysConfigEnt();
XCopyUtils.copyObject(input, entity); XCopyUtils.copyObject(input, entity);
PpsUserSession session = context.getSession(PpsUserSession.class);
entity.setCreateTime(new Date()); entity.setCreateTime(new Date());
entity.setCreateById(context.getUser().getName()); entity.setCreateById(context.getUser().getName());
mapper.insert(entity); mapper.insert(entity);
...@@ -112,7 +110,4 @@ public class BaseSysConfigService { ...@@ -112,7 +110,4 @@ public class BaseSysConfigService {
List<QueryBaseSysConfigViewOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QueryBaseSysConfigViewOutput.class); List<QueryBaseSysConfigViewOutput> outputs = XCopyUtils.copyNewList(pageInfo.getList(), QueryBaseSysConfigViewOutput.class);
return XPageResult.success(outputs, input.getPage(), input.getLimit(), pageInfo.getTotal()); return XPageResult.success(outputs, input.getPage(), input.getLimit(), pageInfo.getTotal());
} }
}
//BEGIN---OF---EXTENSION---CODE---DONT---CHANGE---AND---REMOVE---IT \ No newline at end of file
//END---OF---EXTENSION---CODE---DONT---CHANGE---AND---REMOVE---IT
}
...@@ -56,9 +56,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -56,9 +56,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
element = elements.get(1); //根据页面结构获取到需要的元素对象 element = elements.get(1); //根据页面结构获取到需要的元素对象
} }
Elements tables = element.getElementsByTag("table"); Elements tables = element.getElementsByTag("table");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> hourTimeArray;// 时间 List<String> hourTimeArray;// 时间
List<String> weatherArray; // 天气 List<String> weatherArray; // 天气
List<String> temperatureArray; // 气温 List<String> temperatureArray; // 气温
...@@ -68,7 +66,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -68,7 +66,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
List<String> pressureArray; // 气压 List<String> pressureArray; // 气压
List<String> humidityArray;// 湿度 List<String> humidityArray;// 湿度
List<String> cloudCoverArray; // 云量 List<String> cloudCoverArray; // 云量
Date date = null; Date date = null;
Calendar calendar = null; Calendar calendar = null;
String dayTime = null; String dayTime = null;
...@@ -122,7 +119,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -122,7 +119,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
} }
} }
} }
int Hous = 0; int Hous = 0;
for (int y = 0; y < 8; y++) { for (int y = 0; y < 8; y++) {
PlantPredictedPowerDataEnt dao = new PlantPredictedPowerDataEnt(); PlantPredictedPowerDataEnt dao = new PlantPredictedPowerDataEnt();
...@@ -185,22 +181,18 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -185,22 +181,18 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
BigDecimal temperature_1 = objList.get(i).getTemperature(); BigDecimal temperature_1 = objList.get(i).getTemperature();
BigDecimal temperature_2 = objList.get(I_i).getTemperature(); BigDecimal temperature_2 = objList.get(I_i).getTemperature();
dao.setTemperature(temperature_1.add(temperature_2.subtract(temperature_1).multiply(new BigDecimal(0.3 * y)))); dao.setTemperature(temperature_1.add(temperature_2.subtract(temperature_1).multiply(new BigDecimal(0.3 * y))));
BigDecimal windspeed_1 = objList.get(i).getWindSpeed(); BigDecimal windspeed_1 = objList.get(i).getWindSpeed();
BigDecimal windspeed_2 = objList.get(I_i).getWindSpeed(); BigDecimal windspeed_2 = objList.get(I_i).getWindSpeed();
dao.setWindSpeed(windspeed_1.add(windspeed_2.subtract(windspeed_1).multiply(new BigDecimal(0.3 * y)))); dao.setWindSpeed(windspeed_1.add(windspeed_2.subtract(windspeed_1).multiply(new BigDecimal(0.3 * y))));
dao.setWindDirection(objList.get(i).getWindDirection()); dao.setWindDirection(objList.get(i).getWindDirection());
BigDecimal pressure_1 = objList.get(i).getPressure(); BigDecimal pressure_1 = objList.get(i).getPressure();
BigDecimal pressure_2 = objList.get(I_i).getPressure(); BigDecimal pressure_2 = objList.get(I_i).getPressure();
dao.setPressure(pressure_1.add(pressure_2.subtract(pressure_1).multiply(new BigDecimal(0.3 * y)))); dao.setPressure(pressure_1.add(pressure_2.subtract(pressure_1).multiply(new BigDecimal(0.3 * y))));
BigDecimal humidity_1 = objList.get(i).getHumidity(); BigDecimal humidity_1 = objList.get(i).getHumidity();
BigDecimal humidity_2 = objList.get(I_i).getHumidity(); BigDecimal humidity_2 = objList.get(I_i).getHumidity();
dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(new BigDecimal(0.3 * y)))); dao.setHumidity(humidity_1.add(humidity_2.subtract(humidity_1).multiply(new BigDecimal(0.3 * y))));
date = sdf.parse(objList.get(i).getYearTime() + "-" + objList.get(i).getMonthTime() + "-" + objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getYearTime() + "-" + objList.get(i).getMonthTime() + "-" + objList.get(i).getDayTime());
String Hour = ""; String Hour;
if (23 == Integer.valueOf(objList.get(i).getHourTime())) { if (23 == Integer.valueOf(objList.get(i).getHourTime())) {
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
...@@ -240,7 +232,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -240,7 +232,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
// } // }
} }
} }
List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>(); List<PlantPredictedPowerDataEnt> batchList = new ArrayList<>();
PlantPredictedPowerDataViewMapper dataViewMapper = context.getBean(PlantPredictedPowerDataViewMapper.class); PlantPredictedPowerDataViewMapper dataViewMapper = context.getBean(PlantPredictedPowerDataViewMapper.class);
List<PlantPredictedPowerDataEnt> sortList = allList.stream().sorted(Comparator.comparing(PlantPredictedPowerDataEnt::getDataDate)).collect(Collectors.toList()); List<PlantPredictedPowerDataEnt> sortList = allList.stream().sorted(Comparator.comparing(PlantPredictedPowerDataEnt::getDataDate)).collect(Collectors.toList());
...@@ -315,9 +306,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -315,9 +306,7 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
element = elements.get(1); //根据页面结构获取到需要的元素对象 element = elements.get(1); //根据页面结构获取到需要的元素对象
} }
Elements tables = element.getElementsByTag("table"); Elements tables = element.getElementsByTag("table");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> hourTimeArray;// 时间 List<String> hourTimeArray;// 时间
List<String> weatherArray; // 天气 List<String> weatherArray; // 天气
List<String> temperatureArray; // 气温 List<String> temperatureArray; // 气温
...@@ -327,24 +316,18 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -327,24 +316,18 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
List<String> pressureArray; // 气压 List<String> pressureArray; // 气压
List<String> humidityArray;// 湿度 List<String> humidityArray;// 湿度
List<String> cloudCoverArray; // 云量 List<String> cloudCoverArray; // 云量
Date date;
Date date = null; Calendar calendar;
Calendar calendar = null; String dayTime;
String dayTime = null; BaseWatherEnt dao;
BaseWatherEnt dao = null;
List<BaseWatherEnt> objList = new ArrayList<>(); List<BaseWatherEnt> objList = new ArrayList<>();
if (tables != null && tables.size() > 0) { if (tables != null && tables.size() > 0) {
for (int i = 0; i < tables.size(); i++) { for (int i = 0; i < tables.size(); i++) {
Map<String, List> map1 = new LinkedHashMap<>();
date = new Date();
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, i); calendar.add(Calendar.DATE, i);
date = calendar.getTime(); date = calendar.getTime();
dayTime = sdf.format(date); dayTime = sdf.format(date);
int week = calendar.get(Calendar.DAY_OF_WEEK);
Elements trs = tables.get(i).select("tr"); Elements trs = tables.get(i).select("tr");
hourTimeArray = new ArrayList<>();// 时间 hourTimeArray = new ArrayList<>();// 时间
weatherArray = new ArrayList<>(); // 天气 weatherArray = new ArrayList<>(); // 天气
temperatureArray = new ArrayList<>(); // 气温 temperatureArray = new ArrayList<>(); // 气温
...@@ -357,7 +340,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -357,7 +340,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
if (trs != null && trs.size() > 0) { if (trs != null && trs.size() > 0) {
for (int j = 0; j < trs.size(); j++) { // 循环行 for (int j = 0; j < trs.size(); j++) { // 循环行
Elements tds = trs.get(j).select("td"); Elements tds = trs.get(j).select("td");
for (int k = 1; k < tds.size(); k++) { // 循环列 for (int k = 1; k < tds.size(); k++) { // 循环列
Element td = tds.get(k); Element td = tds.get(k);
String td_text; String td_text;
...@@ -386,7 +368,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -386,7 +368,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
} }
} }
} }
int Hous = 0; int Hous = 0;
for (int y = 0; y < 8; y++) { for (int y = 0; y < 8; y++) {
dao = new BaseWatherEnt(); dao = new BaseWatherEnt();
...@@ -440,27 +421,20 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -440,27 +421,20 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature()); Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature());
Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature()); Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature());
dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃"); dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃");
dao.setPrecipitation(objList.get(i).getPrecipitation()); dao.setPrecipitation(objList.get(i).getPrecipitation());
Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed()); Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed());
Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed()); Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed());
dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s"); dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s");
dao.setWindDirection(objList.get(i).getWindDirection()); dao.setWindDirection(objList.get(i).getWindDirection());
Double pressure_1 = Double.parseDouble(objList.get(i).getPressure()); Double pressure_1 = Double.parseDouble(objList.get(i).getPressure());
Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure()); Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure());
dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa"); dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa");
Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity()); Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity());
Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity()); Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity());
dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%"); dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%");
Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover()); Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover());
Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover()); Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover());
dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%"); dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%");
if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) { if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) {
date = sdf.parse(objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getDayTime());
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
...@@ -519,7 +493,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -519,7 +493,6 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
@Override @Override
public XServiceResult crawlBaseWatherData(XContext context) { public XServiceResult crawlBaseWatherData(XContext context) {
try { try {
//请求省份接口。获取省份列表 //请求省份接口。获取省份列表
String provinceStr = HttpUtils.send2(provinceUrl, String provinceStr = HttpUtils.send2(provinceUrl,
""); "");
...@@ -574,4 +547,4 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService { ...@@ -574,4 +547,4 @@ public class BaseWatherCloudServiceImpl implements BaseWatherCloudService {
crawlPlantBaseWatherData(context); crawlPlantBaseWatherData(context);
return XServiceResult.OK; return XServiceResult.OK;
} }
} }
\ No newline at end of file
...@@ -21,7 +21,10 @@ import xstartup.feature.api.annotation.XApiGet; ...@@ -21,7 +21,10 @@ import xstartup.feature.api.annotation.XApiGet;
import java.net.URL; import java.net.URL;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.*; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@XService @XService
...@@ -33,16 +36,14 @@ public class BaseWatherService { ...@@ -33,16 +36,14 @@ public class BaseWatherService {
WeatherDataMapper mapper = context.getBean(WeatherDataMapper.class); WeatherDataMapper mapper = context.getBean(WeatherDataMapper.class);
Document document = Jsoup.parse(new URL(url), 30000); Document document = Jsoup.parse(new URL(url), 30000);
Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象 Elements elements = document.getElementsByClass("mt15"); // 获取class name 是‘mt15’的都有元素对象
Element element = null; Element element;
if (elements == null || elements.size() <= 0) { if (elements == null || elements.size() <= 0) {
return; return;
} else { } else {
element = elements.get(1); //根据页面结构获取到需要的元素对象 element = elements.get(1); //根据页面结构获取到需要的元素对象
} }
Elements tables = element.getElementsByTag("table"); Elements tables = element.getElementsByTag("table");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> hourTimeArray;// 时间 List<String> hourTimeArray;// 时间
List<String> weatherArray; // 天气 List<String> weatherArray; // 天气
List<String> temperatureArray; // 气温 List<String> temperatureArray; // 气温
...@@ -52,24 +53,18 @@ public class BaseWatherService { ...@@ -52,24 +53,18 @@ public class BaseWatherService {
List<String> pressureArray; // 气压 List<String> pressureArray; // 气压
List<String> humidityArray;// 湿度 List<String> humidityArray;// 湿度
List<String> cloudCoverArray; // 云量 List<String> cloudCoverArray; // 云量
Date date;
Date date = null; Calendar calendar;
Calendar calendar = null; String dayTime;
String dayTime = null; BaseWatherEnt dao;
BaseWatherEnt dao = null;
List<BaseWatherEnt> objList = new ArrayList<>(); List<BaseWatherEnt> objList = new ArrayList<>();
if (tables != null && tables.size() > 0) { if (tables != null && tables.size() > 0) {
for (int i = 0; i < tables.size(); i++) { for (int i = 0; i < tables.size(); i++) {
Map<String, List> map1 = new LinkedHashMap<>();
date = new Date();
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
calendar.add(Calendar.DATE, i); calendar.add(Calendar.DATE, i);
date = calendar.getTime(); date = calendar.getTime();
dayTime = sdf.format(date); dayTime = sdf.format(date);
int week = calendar.get(Calendar.DAY_OF_WEEK);
Elements trs = tables.get(i).select("tr"); Elements trs = tables.get(i).select("tr");
hourTimeArray = new ArrayList<>();// 时间 hourTimeArray = new ArrayList<>();// 时间
weatherArray = new ArrayList<>(); // 天气 weatherArray = new ArrayList<>(); // 天气
temperatureArray = new ArrayList<>(); // 气温 temperatureArray = new ArrayList<>(); // 气温
...@@ -82,7 +77,6 @@ public class BaseWatherService { ...@@ -82,7 +77,6 @@ public class BaseWatherService {
if (trs != null && trs.size() > 0) { if (trs != null && trs.size() > 0) {
for (int j = 0; j < trs.size(); j++) { // 循环行 for (int j = 0; j < trs.size(); j++) { // 循环行
Elements tds = trs.get(j).select("td"); Elements tds = trs.get(j).select("td");
for (int k = 1; k < tds.size(); k++) { // 循环列 for (int k = 1; k < tds.size(); k++) { // 循环列
Element td = tds.get(k); Element td = tds.get(k);
String td_text; String td_text;
...@@ -111,7 +105,6 @@ public class BaseWatherService { ...@@ -111,7 +105,6 @@ public class BaseWatherService {
} }
} }
} }
int Hous = 0; int Hous = 0;
for (int y = 0; y < 8; y++) { for (int y = 0; y < 8; y++) {
dao = new BaseWatherEnt(); dao = new BaseWatherEnt();
...@@ -165,27 +158,20 @@ public class BaseWatherService { ...@@ -165,27 +158,20 @@ public class BaseWatherService {
Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature()); Double temperature_1 = Double.parseDouble(objList.get(i).getTemperature());
Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature()); Double temperature_2 = Double.parseDouble(objList.get(I_i).getTemperature());
dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃"); dao.setTemperature((temperature_1 + (temperature_2 - temperature_1) * (0.3 * y)) + "℃");
dao.setPrecipitation(objList.get(i).getPrecipitation()); dao.setPrecipitation(objList.get(i).getPrecipitation());
Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed()); Double windspeed_1 = Double.parseDouble(objList.get(i).getWindSpeed());
Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed()); Double windspeed_2 = Double.parseDouble(objList.get(I_i).getWindSpeed());
dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s"); dao.setWindSpeed((windspeed_1 + (windspeed_2 - windspeed_1) * (0.3 * y)) + "m/s");
dao.setWindDirection(objList.get(i).getWindDirection()); dao.setWindDirection(objList.get(i).getWindDirection());
Double pressure_1 = Double.parseDouble(objList.get(i).getPressure()); Double pressure_1 = Double.parseDouble(objList.get(i).getPressure());
Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure()); Double pressure_2 = Double.parseDouble(objList.get(I_i).getPressure());
dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa"); dao.setPressure((pressure_1 + (pressure_2 - pressure_1) * (0.3 * y)) + "hPa");
Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity()); Double humidity_1 = Double.parseDouble(objList.get(i).getHumidity());
Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity()); Double humidity_2 = Double.parseDouble(objList.get(I_i).getHumidity());
dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%"); dao.setHumidity((humidity_1 + (humidity_2 - humidity_1) * (0.3 * y)) + "%");
Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover()); Double cloudcover_1 = Double.parseDouble(objList.get(i).getCloudCover());
Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover()); Double cloudcover_2 = Double.parseDouble(objList.get(I_i).getCloudCover());
dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%"); dao.setCloudCover((cloudcover_1 + (cloudcover_2 - cloudcover_1) * (0.3 * y)) + "%");
if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) { if (23 == LocalTime.parse(objList.get(i).getHourTime()).getHour()) {
date = sdf.parse(objList.get(i).getDayTime()); date = sdf.parse(objList.get(i).getDayTime());
calendar = Calendar.getInstance(); calendar = Calendar.getInstance();
...@@ -196,7 +182,7 @@ public class BaseWatherService { ...@@ -196,7 +182,7 @@ public class BaseWatherService {
dao.setHourTime("0" + (y - 1) + ":00:00"); dao.setHourTime("0" + (y - 1) + ":00:00");
} else { } else {
dao.setDayTime(objList.get(i).getDayTime()); dao.setDayTime(objList.get(i).getDayTime());
String Hour = ""; String Hour;
if ((LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) < 10) { if ((LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) < 10) {
Hour = "0" + (LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) + ":00:00"; Hour = "0" + (LocalTime.parse(objList.get(i).getHourTime()).getHour() + y) + ":00:00";
} else { } else {
...@@ -251,12 +237,7 @@ public class BaseWatherService { ...@@ -251,12 +237,7 @@ public class BaseWatherService {
String[] city = cityStr.split(","); String[] city = cityStr.split(",");
String cityCode = city[0];//区编码 String cityCode = city[0];//区编码
String cityName = city[1];//区名称 String cityName = city[1];//区名称
XThreadHelper.async(new Runnable() { XThreadHelper.async(() -> insertData(context, provinceCode, provinceName, cityCode, cityName, 1));
@Override
public void run() {
insertData(context, provinceCode, provinceName, cityCode, cityName, 1);
}
});
} }
} }
} }
...@@ -274,4 +255,4 @@ public class BaseWatherService { ...@@ -274,4 +255,4 @@ public class BaseWatherService {
insertData(context, "ASN", "陕西", "57022", "麟游", 1); insertData(context, "ASN", "陕西", "57022", "麟游", 1);
return XServiceResult.OK; return XServiceResult.OK;
} }
} }
\ No newline at end of file
...@@ -51,15 +51,12 @@ public class CounterService { ...@@ -51,15 +51,12 @@ public class CounterService {
* @param context * @param context
* @return * @return
*/ */
// @XApiAnonymous
@XText("获取集群全局计数器") @XText("获取集群全局计数器")
@XApiGet @XApiGet
public XSingleResult<MyCounterOutput> getClusterGlobalCounter(XContext context) { public XSingleResult<MyCounterOutput> getClusterGlobalCounter(XContext context) {
try { try {
MyCounterOutput finalOutput = new MyCounterOutput(); MyCounterOutput finalOutput = new MyCounterOutput();
String cacheType = XStartup.getCurrent().getProperty("x.cache.type"); String cacheType = XStartup.getCurrent().getProperty("x.cache.type");
String appName = XStartup.getApplication().getName();
String appClusterName = CounterJob5S.getAppClusterName(); String appClusterName = CounterJob5S.getAppClusterName();
String appClusterLockName = CounterJob5S.getAppClusterLockName(); String appClusterLockName = CounterJob5S.getAppClusterLockName();
if ("redis-cluster".equals(cacheType)) { if ("redis-cluster".equals(cacheType)) {
...@@ -68,9 +65,7 @@ public class CounterService { ...@@ -68,9 +65,7 @@ public class CounterService {
finalOutput.put("NODES", XJsonUtils.toJson(nodeKeys)); finalOutput.put("NODES", XJsonUtils.toJson(nodeKeys));
finalOutput.put("MASTER", jedis.get(appClusterLockName)); finalOutput.put("MASTER", jedis.get(appClusterLockName));
nodeKeys.forEach(k -> { nodeKeys.forEach(k -> {
if (!jedis.exists(k)) { if (jedis.exists(k)) {
return;
} else {
String dynObjJson = jedis.get(k); String dynObjJson = jedis.get(k);
DynObj dynObj = XJsonUtils.toObject(dynObjJson, DynObj.class); DynObj dynObj = XJsonUtils.toObject(dynObjJson, DynObj.class);
String owner = dynObj.getString(CounterBuilder.COUNTER_NAME_OWNER); String owner = dynObj.getString(CounterBuilder.COUNTER_NAME_OWNER);
...@@ -87,9 +82,7 @@ public class CounterService { ...@@ -87,9 +82,7 @@ public class CounterService {
finalOutput.put("NODES", XJsonUtils.toJson(nodeKeys)); finalOutput.put("NODES", XJsonUtils.toJson(nodeKeys));
finalOutput.put("MASTER", jedis.get(appClusterLockName)); finalOutput.put("MASTER", jedis.get(appClusterLockName));
nodeKeys.forEach(k -> { nodeKeys.forEach(k -> {
if (!jedis.exists(k)) { if (jedis.exists(k)) {
return;
} else {
String dynObjJson = jedis.get(k); String dynObjJson = jedis.get(k);
DynObj dynObj = XJsonUtils.toObject(dynObjJson, DynObj.class); DynObj dynObj = XJsonUtils.toObject(dynObjJson, DynObj.class);
String owner = dynObj.getString(CounterBuilder.COUNTER_NAME_OWNER); String owner = dynObj.getString(CounterBuilder.COUNTER_NAME_OWNER);
...@@ -101,7 +94,6 @@ public class CounterService { ...@@ -101,7 +94,6 @@ public class CounterService {
}); });
}); });
} }
return XSingleResult.success(finalOutput); return XSingleResult.success(finalOutput);
} catch (Exception ex) { } catch (Exception ex) {
CounterBuilder.globalCounterBuilder.addCounter(ex, this.getClass()); CounterBuilder.globalCounterBuilder.addCounter(ex, this.getClass());
...@@ -119,4 +111,4 @@ public class CounterService { ...@@ -119,4 +111,4 @@ public class CounterService {
output.put("threads", list); output.put("threads", list);
return XSingleResult.success(output); return XSingleResult.success(output);
} }
} }
\ No newline at end of file
...@@ -191,5 +191,4 @@ public class SysPageInfoService { ...@@ -191,5 +191,4 @@ public class SysPageInfoService {
XCopyUtils.copyObject(entity, output); XCopyUtils.copyObject(entity, output);
return XSingleResult.success(output); return XSingleResult.success(output);
} }
}
} \ 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