|
@@ -1,13 +1,28 @@
|
|
|
package com.jiayue.biz.job;
|
|
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
|
+import com.jiayue.biz.domain.ProphaseAnemometryData;
|
|
|
+import com.jiayue.biz.domain.ProphaseWeatherData;
|
|
|
+import com.jiayue.biz.domain.WindTowerInfo;
|
|
|
+import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
|
|
|
+import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
|
|
|
+import com.jiayue.biz.service.WindTowerDataParentTableService;
|
|
|
+import com.jiayue.biz.service.WindTowerInfoService;
|
|
|
import com.jiayue.biz.service.impl.AnalysisDataImpl;
|
|
|
import com.jiayue.biz.service.impl.EmailImpl;
|
|
|
+import com.jiayue.biz.util.CalculationUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.sql.Timestamp;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* 定时扫描系统邮件并解析
|
|
|
*
|
|
@@ -23,6 +38,18 @@ public class FileAnalysisJob {
|
|
|
private final EmailImpl emailImpl;
|
|
|
@Autowired
|
|
|
AnalysisDataImpl analysisData;
|
|
|
+ @Autowired
|
|
|
+ WindTowerInfoService windTowerInfoService;
|
|
|
+ @Autowired
|
|
|
+ WindTowerDataParentTableService windTowerDataParentTableService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ProphaseWeatherDataMapper prophaseWeatherDataMapper;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public FileAnalysisJob(EmailImpl emailImpl) {
|
|
|
this.emailImpl = emailImpl;
|
|
@@ -49,5 +76,91 @@ public class FileAnalysisJob {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Scheduled(cron = "0 20 16 21 4 ? ")
|
|
|
+ public void testNew() {
|
|
|
+ List<WindTowerInfo> list1 = windTowerInfoService.lambdaQuery().list();
|
|
|
+ List<WindTowerInfo> collect = list1.stream().filter(w -> w.getType().equals("1")).collect(Collectors.toList());
|
|
|
+ for (WindTowerInfo windTowerInfo : collect) {
|
|
|
+ Date date = new Date(1606752000000l);
|
|
|
+ String equipmentId = windTowerInfo.getEquipmentNo();
|
|
|
+// List<WindTowerInfo> list = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
|
|
|
+ HashSet<String> dataSet = new HashSet<>();
|
|
|
+ String heights = windTowerInfo.getHeights();
|
|
|
+ String wdHeights = windTowerInfo.getWdHeights();
|
|
|
+ dataSet.addAll(Arrays.asList(heights.split(",")));
|
|
|
+ dataSet.addAll(Arrays.asList(wdHeights.split(",")));
|
|
|
+ for (long i = date.getTime(); i < 1680278400000l; i = DateUtil.offsetMonth(new Date(i), 1).getTime()) {
|
|
|
+ long l = DateUtil.offsetMonth(new Date(i), 1).getTime();
|
|
|
+ List<Map<String, Object>> mapList = windTowerDataParentTableService.selectByBetweenTimeAndEquipmetIdOld(new Date(i), new Date(l), equipmentId);
|
|
|
+ if (mapList.size() > 0) {
|
|
|
+ ArrayList<ProphaseWeatherData> prophaseAnemometryPublicDataArrayList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+
|
|
|
+ //公共部分
|
|
|
+ ProphaseWeatherData prophaseAnemometryPublicData = new ProphaseWeatherData();
|
|
|
+ prophaseAnemometryPublicData.setTs(new Timestamp(Long.parseLong(map.get("time").toString())));
|
|
|
+ prophaseAnemometryPublicData.setTInst(!map.containsKey("t_inst") ? null : Float.parseFloat(map.get("t_inst").toString()));
|
|
|
+ prophaseAnemometryPublicData.setTAve(!map.containsKey("t_ave") ? null : Float.parseFloat(map.get("t_ave").toString()));
|
|
|
+ prophaseAnemometryPublicData.setTMax(!map.containsKey("t_max") ? null : Float.parseFloat(map.get("t_max").toString()));
|
|
|
+ prophaseAnemometryPublicData.setTMin(!map.containsKey("t_min") ? null : Float.parseFloat(map.get("t_min").toString()));
|
|
|
+ prophaseAnemometryPublicData.setTSta(!map.containsKey("t_sta") ? null : Float.parseFloat(map.get("t_sta").toString()));
|
|
|
+
|
|
|
+ prophaseAnemometryPublicData.setRhInst(!map.containsKey("rh_inst") ? null : Float.parseFloat(map.get("rh_inst").toString()));
|
|
|
+ prophaseAnemometryPublicData.setRhAve(!map.containsKey("rh_ave") ? null : Float.parseFloat(map.get("rh_ave").toString()));
|
|
|
+ prophaseAnemometryPublicData.setRhMax(!map.containsKey("rh_max") ? null : Float.parseFloat(map.get("rh_max").toString()));
|
|
|
+ prophaseAnemometryPublicData.setRhMin(!map.containsKey("rh_min") ? null : Float.parseFloat(map.get("rh_min").toString()));
|
|
|
+ prophaseAnemometryPublicData.setRhSta(!map.containsKey("rh_sta") ? null : Float.parseFloat(map.get("rh_sta").toString()));
|
|
|
+
|
|
|
+ prophaseAnemometryPublicData.setPaInst(!map.containsKey("pa_inst") ? null : Float.parseFloat(map.get("pa_inst").toString()));
|
|
|
+ prophaseAnemometryPublicData.setPaAve(!map.containsKey("pa_ave") ? null : Float.parseFloat(map.get("pa_ave").toString()));
|
|
|
+ prophaseAnemometryPublicData.setPaMax(!map.containsKey("pa_max") ? null : Float.parseFloat(map.get("pa_max").toString()));
|
|
|
+ prophaseAnemometryPublicData.setPaMin(!map.containsKey("pa_min") ? null : Float.parseFloat(map.get("pa_min").toString()));
|
|
|
+ prophaseAnemometryPublicData.setPaSta(!map.containsKey("pa_sta") ? null : Float.parseFloat(map.get("pa_sta").toString()));
|
|
|
+
|
|
|
+ prophaseAnemometryPublicData.setAirDensity(!map.containsKey("air_density") ? null : Float.parseFloat(map.get("air_density").toString()));
|
|
|
+ prophaseAnemometryPublicDataArrayList.add(prophaseAnemometryPublicData);
|
|
|
+ }
|
|
|
+ //切分List
|
|
|
+ List<List<ProphaseWeatherData>> partition = ListUtil.partition(prophaseAnemometryPublicDataArrayList, 3000);
|
|
|
+ //分批保存
|
|
|
+ for (List<ProphaseWeatherData> prophaseAnemometryPublicDataList : partition) {
|
|
|
+ prophaseWeatherDataMapper.insertSplice(prophaseAnemometryPublicDataList, equipmentId);
|
|
|
+ }
|
|
|
+ ArrayList<ProphaseAnemometryData> prophaseAnemometryDataArrayList = new ArrayList<>();
|
|
|
+ for (String height : dataSet) {
|
|
|
+ for (Map<String, Object> m : mapList) {
|
|
|
+ //风速 风向
|
|
|
+ ProphaseAnemometryData one = new ProphaseAnemometryData();
|
|
|
+ //组装子表数据
|
|
|
+ one.setWsAve(!m.containsKey("ws_ave" + height) ? null : CalculationUtil.getBigDecimal(m.get("ws_ave" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWsMax(!m.containsKey("ws_max" + height) ? null : CalculationUtil.getBigDecimal(m.get("ws_max" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWsMin(!m.containsKey("ws_min" + height) ? null : CalculationUtil.getBigDecimal(m.get("ws_min" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWsSta(!m.containsKey("ws_sta" + height) ? null : CalculationUtil.getBigDecimal(m.get("ws_sta" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWsInst(!m.containsKey("ws_inst" + height) ? null : CalculationUtil.getBigDecimal(m.get("ws_inst" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWdAve(!m.containsKey("wd_ave" + height) ? null : CalculationUtil.getBigDecimal(m.get("wd_ave" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWdMax(!m.containsKey("wd_max" + height) ? null : CalculationUtil.getBigDecimal(m.get("wd_max" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWdMin(!m.containsKey("wd_min" + height) ? null : CalculationUtil.getBigDecimal(m.get("wd_min" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWdSta(!m.containsKey("wd_sta" + height) ? null : CalculationUtil.getBigDecimal(m.get("wd_sta" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+ one.setWdInst(!m.containsKey("wd_inst" + height) ? null : CalculationUtil.getBigDecimal(m.get("wd_inst" + height)).setScale(2, RoundingMode.HALF_UP).floatValue());
|
|
|
+
|
|
|
+ one.setTs(new Timestamp(Long.parseLong(m.get("time").toString())));
|
|
|
+ prophaseAnemometryDataArrayList.add(one);
|
|
|
+ }
|
|
|
+ //切分List
|
|
|
+ List<List<ProphaseAnemometryData>> partition1 = ListUtil.partition(prophaseAnemometryDataArrayList, 3000);
|
|
|
+ //分批保存
|
|
|
+ for (List<ProphaseAnemometryData> prophaseAnemometryData : partition1) {
|
|
|
+ prophaseAnemometryDataMapper.insertSplice(prophaseAnemometryData, equipmentId, height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|