Sfoglia il codice sorgente

整理tdEngine mapper到service

hxf 2 anni fa
parent
commit
a2df0ab71f

+ 6 - 9
neim-biz/src/main/java/com/jiayue/biz/job/AirDensityJob.java

@@ -7,10 +7,7 @@ import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.jiayue.biz.domain.*;
 import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
-import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
-import com.jiayue.biz.service.EquipmentAttributeService;
-import com.jiayue.biz.service.StationInfoService;
-import com.jiayue.biz.service.WindTowerDataParentTableService;
+import com.jiayue.biz.service.*;
 import com.jiayue.biz.service.impl.*;
 import com.jiayue.biz.util.DateTimeUtil;
 import com.jiayue.common.utils.DateUtil;
@@ -47,9 +44,9 @@ public class AirDensityJob {
 
     private final WindTowerDataParentTableService windTowerDataParentTableService;
 
-    private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
+    private final ProphaseAnemometryDataService prophaseAnemometryDataService;
 
-    private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    private final ProphaseWeatherDataService prophaseWeatherDataService;
 
 
     private final StationInfoService stationInfoService;
@@ -76,7 +73,7 @@ public class AirDensityJob {
             Date sevenDate = startDate;
             //获取统计数据最后一条数据
             WindTowerCalculationData lastData = windTowerCalculationDataService.getLastDataCalculation(windTowerInfo.getEquipmentNo());
-            List<Entity> firstData = prophaseWeatherDataMapper.getFirstData(windTowerInfo.getEquipmentNo());
+            List<Entity> firstData = prophaseWeatherDataService.getFirstData(windTowerInfo.getEquipmentNo());
             //获取统计数据最后一条的当月开始时间 作为查询时间使用
             Date startTime = (Timestamp) firstData.get(0).get("first (ts)");
             //获取统计数据最后一天的数据时间第二天的 00 点
@@ -90,9 +87,9 @@ public class AirDensityJob {
                 sevenDate = startTime;
             }
             //风数据查询
-            List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectAll(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()) ,new Timestamp(endDate.getTime()));
+            List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAll(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()) ,new Timestamp(endDate.getTime()));
             //环境数据查询
-            List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataMapper.selectPublicData(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()), new Timestamp(endDate.getTime()));
+            List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectPublicData(windTowerInfo.getEquipmentNo(), new Timestamp(startTime.getTime()), new Timestamp(endDate.getTime()));
             //统计数据
             List<WindTowerCalculationData> windTowerCalculationDataList = windTowerCalculationDataService.getByBetweenTimeAndEquipmentId(startTime, endDate, windTowerInfo.getEquipmentNo());
             //小时平均风速风功率密度

+ 9 - 4
neim-biz/src/main/java/com/jiayue/biz/job/FileAnalysisJob.java

@@ -7,6 +7,8 @@ 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.ProphaseAnemometryDataService;
+import com.jiayue.biz.service.ProphaseWeatherDataService;
 import com.jiayue.biz.service.WindTowerDataParentTableService;
 import com.jiayue.biz.service.WindTowerInfoService;
 import com.jiayue.biz.service.impl.AnalysisDataImpl;
@@ -44,10 +46,13 @@ public class FileAnalysisJob {
     WindTowerDataParentTableService windTowerDataParentTableService;
 
     @Autowired
-    ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
+    ProphaseAnemometryDataService prophaseAnemometryDataService;
 
     @Autowired
-    ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    ProphaseWeatherDataService prophaseWeatherDataService;
+
+
+
 
 
 
@@ -123,7 +128,7 @@ public class FileAnalysisJob {
                     List<List<ProphaseWeatherData>> partition = ListUtil.partition(prophaseAnemometryPublicDataArrayList, 3000);
                     //分批保存
                     for (List<ProphaseWeatherData> prophaseAnemometryPublicDataList : partition) {
-                        prophaseWeatherDataMapper.insertSplice(prophaseAnemometryPublicDataList, equipmentId);
+                        prophaseWeatherDataService.insertSplice(prophaseAnemometryPublicDataList, equipmentId);
                     }
                     ArrayList<ProphaseAnemometryData> prophaseAnemometryDataArrayList = new ArrayList<>();
                     for (String height : dataSet) {
@@ -145,7 +150,7 @@ public class FileAnalysisJob {
                             one.setEquipmentId(windTowerInfo.getEquipmentNo());
                             one.setTs(new Timestamp(Long.parseLong(m.get("time").toString())));
 
-                            prophaseAnemometryDataMapper.insertOneWithNew(one);
+                            prophaseAnemometryDataService.insertOneWithNew(one);
 //                            prophaseAnemometryDataArrayList.add(one);
                         }
                         //切分List

+ 2 - 2
neim-biz/src/main/java/com/jiayue/biz/mapper/ProphaseAnemometryDataMapper.java

@@ -57,12 +57,12 @@ public interface ProphaseAnemometryDataMapper extends BaseMapper<ProphaseAnemome
     @Select("SELECT t1.ts,t1.wd_ave FROM prophase_anemometry_data t1 where t1.layer_height = #{height} and t1.equipment_id = #{equipmentId} and  t1.ts >= #{startTime} and t1.ts <= #{endTime}")
     List<ProphaseAnemometryData> selectWdAveForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
 
-    //根据层高和设备编号查询风向
+    //根据层高和设备编号查询风向、风速、标差
     @Select("SELECT t1.ts,t1.ws_ave,t1.ws_sta,t1.wd_ave FROM prophase_anemometry_data t1 where t1.layer_height = #{height} and t1.equipment_id = #{equipmentId} and  t1.ts >= #{startTime} and t1.ts <= #{endTime}")
     List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime,@Param("height") String height);
 
 
-    //查询设备编号查询风向 风速 风速标差
+    //查询设备编号查询所有层高风向 风速 风速标差
     @Select("SELECT t1.ts,t1.ws_ave,t1.ws_sta,t1.wd_ave,t1.layer_height FROM prophase_anemometry_data t1 where  t1.equipment_id = #{equipmentId} and  t1.ts >= #{startTime} and t1.ts <= #{endTime}")
     List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(@Param("equipmentId") String equipmentId, @Param("startTime") Timestamp startTime, @Param("endTime") Timestamp endTime);
 

+ 34 - 1
neim-biz/src/main/java/com/jiayue/biz/service/ProphaseAnemometryDataService.java

@@ -3,12 +3,45 @@ package com.jiayue.biz.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jiayue.biz.domain.ProphaseAnemometryData;
 
+import java.sql.Timestamp;
 import java.util.Date;
 import java.util.List;
 
 public interface ProphaseAnemometryDataService extends IService<ProphaseAnemometryData> {
 
     //查询风时间段内所有数据
-    List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime,Date endTime);
+    List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime, Date endTime);
+
+
+    //单条插入
+    int insertOneWithNew(ProphaseAnemometryData one);
+
+
+    //查询所有数据
+    List<ProphaseAnemometryData> selectAll(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //所有层高风速风向平均值
+    List<ProphaseAnemometryData> selectAve(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //查询所有层高风速以及风速标差
+    List<ProphaseAnemometryData> selectAveAndSta(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //查询所有层高风速
+    List<ProphaseAnemometryData> selectWsAve(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //根据层高和设备编号查询风速
+    List<ProphaseAnemometryData> selectWsAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height);
+
+
+    //根据层高和设备编号查询风向
+    List<ProphaseAnemometryData> selectWdAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height);
+
+
+    //根据层高和设备编号查询风向、风速、标差
+    List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height);
+
+    //查询设备编号查询所有层高风向 风速 风速标差
+    List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(String equipmentId, Timestamp startTime, Timestamp endTime);
+
 
 }

+ 33 - 1
neim-biz/src/main/java/com/jiayue/biz/service/ProphaseWeatherDataService.java

@@ -1,14 +1,46 @@
 package com.jiayue.biz.service;
 
+import cn.hutool.db.Entity;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.jiayue.biz.domain.ProphaseWeatherData;
 
+import java.sql.Timestamp;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 public interface ProphaseWeatherDataService extends IService<ProphaseWeatherData> {
     //获取测风塔起止时间
-     Map<String, Long> getDataTimeStartAndEnd(String equipmentNo);
+    Map<String, Long> getDataTimeStartAndEnd(String equipmentNo);
+
+    //根据设备编号取出所有条数
+    /*
+    td engine 取出的时间需要截取字段
+    String wstart = entity.get("_wstart").toString().substring(0, 10);
+    formatMap.put(wstart, entity.get("count(*)"));
+     */
+    List<Entity> selectCount(String equipmentNo);
+
+    //查询温度平均值、压强平均值、空气密度
+    List<ProphaseWeatherData> selectTAveAndPaAveAndAir(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //查询空气密度
+    List<ProphaseWeatherData> selectAir(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //查询最开始一条记录
+    List<Entity> getFirstData(String equipmentId);
+
+    //查询最后一条记录
+    List<Entity> getLastData(String equipmentId);
+
+    //批量保存
+    int insertSplice(List<ProphaseWeatherData> prophaseWeatherDataList, String equipmentId);
+
+    //查询所有数据
+    List<ProphaseWeatherData> selectPublicData(String equipmentId, Timestamp startTime, Timestamp endTime);
+
+    //删除时间段内数据
+    void deleteData(String equipmentId, Timestamp startTime, Timestamp endTime);
 
 }

+ 3 - 2
neim-biz/src/main/java/com/jiayue/biz/service/impl/DataRecalculationImpl.java

@@ -10,6 +10,7 @@ import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
 import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
 import com.jiayue.biz.service.DataRecalculationService;
 import com.jiayue.biz.service.EquipmentAttributeService;
+import com.jiayue.biz.service.ProphaseWeatherDataService;
 import com.jiayue.biz.service.WindTowerDataChildTableService;
 import com.jiayue.biz.util.DateTimeUtil;
 import com.jiayue.biz.util.FileUtil;
@@ -57,7 +58,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
 
     private AnalysisDataImpl analysisData;
 
-    private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    private final ProphaseWeatherDataService prophaseWeatherDataService;
     private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
 
 
@@ -612,7 +613,7 @@ public class DataRecalculationImpl implements DataRecalculationService {
                     .le(ProphaseAnemometryData::getTs, new Timestamp(endTime.getTime()))
                     .ge(ProphaseAnemometryData::getTs, new Timestamp(startTime.getTime())));
             //环境数据查询
-            List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataMapper.selectPublicData(equipmentNo, new Timestamp(startTime.getTime()), new Timestamp(endTime.getTime()));
+            List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectPublicData(equipmentNo, new Timestamp(startTime.getTime()), new Timestamp(endTime.getTime()));
             //把传入的时间按照日或月分割
             log.info("开始重新计算统计数据");
             ArrayList<WindTowerCalculationData> allDataList = new ArrayList<>();

+ 17 - 18
neim-biz/src/main/java/com/jiayue/biz/service/impl/HomePageServiceImpl.java

@@ -60,8 +60,7 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
     private final TotalityInfoService totalityInfoService;
     private final FanModelDataService fanModelDataService;
 
-    private final ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
-    private final ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    private final ProphaseAnemometryDataService prophaseAnemometryDataService;
 
     private final ProphaseWeatherDataService prophaseWeatherDataService;
 
@@ -94,18 +93,18 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             try {
                 Date startDate = sdf.parse(month);
                 Date endDate = DateTimeUtil.endOfMonth(startDate);
-                prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
-                weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
             } catch (ParseException e) {
                 e.printStackTrace();
             }
         } else {
             // 最新一天数据
-            List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
+            List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
             Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
             DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
-            prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
-            weatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
+            prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
+            weatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
 
         }
         //时间和空气密度map
@@ -355,16 +354,16 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             try {
                 Date startDate = sdf.parse(month);
                 Date endDate = DateTimeUtil.endOfMonth(startDate);
-                anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
+                anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()), height);
             } catch (ParseException e) {
                 e.printStackTrace();
             }
         } else {
             // 最新一天数据
-            List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
+            List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
             Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
             DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
-            anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
+            anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, new Timestamp(startTime.getTime()), timeEnd, height);
         }
 
         HashMap<String, Integer> hashMap = new HashMap<>();
@@ -461,16 +460,16 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             try {
                 Date startDate = sdf.parse(month);
                 Date endDate = DateTimeUtil.endOfMonth(startDate);
-                mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
             } catch (ParseException e) {
                 e.printStackTrace();
             }
         } else {
             // 最新一天数据
-            List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
+            List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
             Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
             DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
-            mapList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
+            mapList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
 
         }
         HashMap<String, Object> everyMap = new HashMap();
@@ -573,18 +572,18 @@ public class HomePageServiceImpl extends ServiceImpl<WindTowerDataParentTableMap
             try {
                 Date startDate = sdf.parse(month);
                 Date endDate = DateTimeUtil.endOfMonth(startDate);
-                weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
-                anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                weatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
+                anemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startDate.getTime()), new Timestamp(endDate.getTime()));
             } catch (ParseException e) {
                 e.printStackTrace();
             }
         } else {
-            List<Entity> lastData = prophaseWeatherDataMapper.getLastData(equipmentId);
+            List<Entity> lastData = prophaseWeatherDataService.getLastData(equipmentId);
             Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
             DateTime startTime = DateUtil.beginOfDay(new Date(timeEnd.getTime()));
             // 最新一天数据
-            weatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
-            anemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
+            weatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
+            anemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(equipmentId, new Timestamp(startTime.getTime()), timeEnd);
         }
 
         HashMap<String, Object> dataMap = new HashMap<>();

+ 55 - 10
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseAnemometryDataServiceImpl.java

@@ -8,6 +8,8 @@ import com.jiayue.biz.domain.ProphaseAnemometryData;
 import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
 import com.jiayue.biz.service.ProphaseAnemometryDataService;
 import lombok.AllArgsConstructor;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import org.springframework.stereotype.Service;
 
 import java.sql.Timestamp;
@@ -16,29 +18,72 @@ import java.util.List;
 
 @Service
 @AllArgsConstructor
-public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemometryDataMapper,ProphaseAnemometryData> implements ProphaseAnemometryDataService {
+public class ProphaseAnemometryDataServiceImpl extends ServiceImpl<ProphaseAnemometryDataMapper, ProphaseAnemometryData> implements ProphaseAnemometryDataService {
 
 
     //查询风时间段内所有数据
-    public List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime,Date endTime){
-       return list(this.lambdaQueryWrapper(equipmentId,startTime,endTime));
+    public List<ProphaseAnemometryData> selectWsAndWdForTime(String equipmentId, Date startTime, Date endTime) {
+        return list(this.lambdaQueryWrapper(equipmentId, startTime, endTime));
     }
 
 
-
-    private LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper(String equipmentId, Date startTime,Date endTime){
+    private LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper(String equipmentId, Date startTime, Date endTime) {
         LambdaQueryWrapper<ProphaseAnemometryData> lambdaQueryWrapper = Wrappers.lambdaQuery();
-        if(StrUtil.isNotBlank(equipmentId)){
-            lambdaQueryWrapper.eq(ProphaseAnemometryData::getEquipmentId,equipmentId);
+        if (StrUtil.isNotBlank(equipmentId)) {
+            lambdaQueryWrapper.eq(ProphaseAnemometryData::getEquipmentId, equipmentId);
         }
-        if(startTime != null && endTime != null){
-            lambdaQueryWrapper.ge(ProphaseAnemometryData::getTs,new Timestamp(startTime.getTime()));
-            lambdaQueryWrapper.le(ProphaseAnemometryData::getTs,new Timestamp(endTime.getTime()));
+        if (startTime != null && endTime != null) {
+            lambdaQueryWrapper.ge(ProphaseAnemometryData::getTs, new Timestamp(startTime.getTime()));
+            lambdaQueryWrapper.le(ProphaseAnemometryData::getTs, new Timestamp(endTime.getTime()));
         }
         return lambdaQueryWrapper;
 
     }
 
+    //单条插入
+    public int insertOneWithNew(ProphaseAnemometryData one) {
+        return baseMapper.insertOneWithNew(one);
+    }
+
+
+    //查询所有数据
+    public List<ProphaseAnemometryData> selectAll(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectAll(equipmentId, startTime, endTime);
+    }
+
+    //所有层高风速风向平均值
+    public List<ProphaseAnemometryData> selectAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectAve(equipmentId, startTime, endTime);
+    }
+
+    //查询所有层高风速以及风速标差
+    public  List<ProphaseAnemometryData> selectAveAndSta(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectAveAndSta(equipmentId, startTime, endTime);
+    }
+
+    //查询所有层高风速
+    public List<ProphaseAnemometryData> selectWsAve(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectWsAve(equipmentId, startTime, endTime);
+    }
 
+    //根据层高和设备编号查询风速
+    public List<ProphaseAnemometryData> selectWsAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height) {
+        return baseMapper.selectWsAveForHeight(equipmentId, startTime, endTime, height);
+    }
 
+
+    //根据层高和设备编号查询风向
+    public   List<ProphaseAnemometryData> selectWdAveForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height){
+        return baseMapper.selectWdAveForHeight(equipmentId, startTime, endTime, height);
+    }
+
+    //根据层高和设备编号查询风向、风速、标差
+    public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsStaForHeight(String equipmentId, Timestamp startTime, Timestamp endTime, String height){
+        return baseMapper.selectWdAveAndWdAveAndWsStaForHeight(equipmentId, startTime, endTime, height);
+    }
+
+    //查询设备编号查询所有层高风向 风速 风速标差
+    public List<ProphaseAnemometryData> selectWdAveAndWdAveAndWsSta(String equipmentId, Timestamp startTime, Timestamp endTime){
+        return baseMapper.selectWdAveAndWdAveAndWsSta(equipmentId, startTime, endTime);
+    }
 }

+ 49 - 3
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProphaseWeatherDataServiceImpl.java

@@ -6,6 +6,7 @@ import com.jiayue.biz.domain.ProphaseWeatherData;
 import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
 import com.jiayue.biz.service.ProphaseWeatherDataService;
 import lombok.AllArgsConstructor;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Service;
 
 import java.sql.Timestamp;
@@ -23,14 +24,59 @@ public class ProphaseWeatherDataServiceImpl extends ServiceImpl<ProphaseWeatherD
         HashMap<String, Long> hashMap = new HashMap<>();
         List<Entity> lastData = baseMapper.getLastData(equipmentNo);
         List<Entity> firstData = baseMapper.getFirstData(equipmentNo);
-        if(!lastData.isEmpty() && !firstData.isEmpty()){
+        if (!lastData.isEmpty() && !firstData.isEmpty()) {
             Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
             Timestamp timeStart = (Timestamp) firstData.get(0).get("first (ts)");
-            hashMap.put("startTime",timeStart.getTime());
-            hashMap.put("endTime",timeEnd.getTime());
+            hashMap.put("startTime", timeStart.getTime());
+            hashMap.put("endTime", timeEnd.getTime());
         }
         return hashMap;
     }
 
+    //根据设备编号取出所有条数
+    /*
+    td engine 取出的时间需要截取字段
+    String wstart = entity.get("_wstart").toString().substring(0, 10);
+    formatMap.put(wstart, entity.get("count(*)"));
+     */
+    public List<Entity> selectCount(String equipmentNo) {
+        return baseMapper.selectCount(equipmentNo);
+
+    }
+
+    //查询温度平均值、压强平均值、空气密度
+    public List<ProphaseWeatherData> selectTAveAndPaAveAndAir(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectTAveAndPaAveAndAir(equipmentId, startTime, endTime);
+    }
+
+    //查询空气密度
+    public List<ProphaseWeatherData> selectAir(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectAir(equipmentId, startTime, endTime);
+    }
+
+    //查询最开始一条记录
+    public List<Entity> getFirstData(String equipmentId) {
+        return baseMapper.getFirstData(equipmentId);
+    }
+
+    //查询最后一条记录
+    public List<Entity> getLastData(String equipmentId) {
+        return baseMapper.getLastData(equipmentId);
+    }
+
+    //批量保存
+    public int insertSplice(List<ProphaseWeatherData> prophaseWeatherDataList, String equipmentId) {
+        return baseMapper.insertSplice(prophaseWeatherDataList, equipmentId);
+    }
+
+    //查询所有数据
+    public List<ProphaseWeatherData> selectPublicData(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        return baseMapper.selectPublicData(equipmentId, startTime, endTime);
+    }
+    //删除时间段内数据
+    public void deleteData(String equipmentId, Timestamp startTime, Timestamp endTime) {
+        baseMapper.deleteData(equipmentId, startTime, endTime);
+    }
+
 
 }

+ 15 - 15
neim-biz/src/main/java/com/jiayue/biz/service/impl/RealTimeDisplayServiceImpl.java

@@ -36,9 +36,9 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
     private WindTowerInfoService windTowerInfoService;
     private StatisticsSituationService statisticsSituationService;
 
-    private ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
+    private ProphaseAnemometryDataService prophaseAnemometryDataService;
 
-    private ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    private ProphaseWeatherDataService prophaseWeatherDataService;
 
     private final double e = 2.71828183;
 
@@ -54,7 +54,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      */
     public List<Map<String, Object>> turbulence(Long startTime, Long endTime, String equipmentId, String height) {
         //查询所有数据
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectAveAndSta(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAveAndSta(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         ArrayList densityList = new ArrayList<>();
         ArrayList<HashMap<String, Object>> densityList2 = new ArrayList<>();
         ArrayList<HashMap<String, Object>> densityList3 = new ArrayList<>();
@@ -189,7 +189,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
             timeList.add(sdf.format(new Date(i)));
         }
         // 测风塔数据集合
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectAve(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectAve(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         List<WindTowerInfo> windTowerInfoList = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
         String[] wdHeight = windTowerInfoList.get(0).getWdHeights().split(",");
         if (height == null || height.equals("")) {
@@ -283,7 +283,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      */
     public List<Object> weibull(Long startTime, Long endTime, String equipmentId, String height) {
         //查询实时数据
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAve(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAve(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         List<ProphaseAnemometryData> dataList = prophaseAnemometryDataList.stream().filter(p -> p.getLayerHeight().equals(height)).collect(Collectors.toList());
 
 
@@ -381,7 +381,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
         for (WindTowerInfo windTowerInfo : windTowerInfoList) {
             HashMap<String, Object> hashMap = new HashMap<>();
             //获取最后一条数据
-            List<Entity> lastData = prophaseWeatherDataMapper.getLastData(windTowerInfo.getEquipmentNo());
+            List<Entity> lastData = prophaseWeatherDataService.getLastData(windTowerInfo.getEquipmentNo());
             if (lastData.size() > 0) {
                 Timestamp timeEnd = (Timestamp) lastData.get(0).get("last (ts)");
                 long lastDataTime = timeEnd.getTime();
@@ -409,7 +409,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
         List paList = new ArrayList();
         List timeList = new ArrayList();
         //所有数据
-        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataMapper.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectTAveAndPaAveAndAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
         if (prophaseWeatherDataList.size() > 0) {
 
             SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -483,8 +483,8 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      */
     public Map<String, Object> getWindPowerDensityAndAverageWindSpeed(Long startTime, Long endTime, String height, String equipmentId) {
         startTime = DateUtil.beginOfDay(new Date(startTime)).getTime();
-        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataMapper.selectAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWsAveForHeight(equipmentId, new Timestamp(startTime), new Timestamp(endTime), height);
+        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectAir(equipmentId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWsAveForHeight(equipmentId, new Timestamp(startTime), new Timestamp(endTime), height);
         SimpleDateFormat sdf = new SimpleDateFormat("HH");
         SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
         //曲线图
@@ -626,7 +626,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
             String[] startTimeAndEndTime = collectStatisticsSituationList.get(0).getStartTimeAndEndTime().split(",");
             Date startTime = DateTimeUtil.beginOfMonth(new Date(Long.parseLong(startTimeAndEndTime[0])));
 
-            List<Entity> entities = prophaseWeatherDataMapper.selectCount(equipmentNo);
+            List<Entity> entities = prophaseWeatherDataService.selectCount(equipmentNo);
             Map<Object, Object> formatMap = new HashMap<>();
             for (Entity entity : entities) {
                 // td engine 取出的时间需要截取字段
@@ -696,7 +696,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      * @param height
      */
     public List<Map<String, Object>> getWindShear(Long startTime, Long endTime, String eqId, String height) {
-        List<ProphaseAnemometryData> anemometryData = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsSta(eqId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseAnemometryData> anemometryData = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsSta(eqId, new Timestamp(startTime), new Timestamp(endTime));
         String[] heights = windTowerInfoService.getByEquipmentNo(eqId).get(0).getHeights().split(",");
         ArrayList<String> heightAll = new ArrayList<>(Arrays.asList(heights));
         //获取最小层高
@@ -742,7 +742,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      * @param height
      */
     public List<Map<String, Object>> getTurbulenceIntensity(Long startTime, Long endTime, String eqId, String height) {
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(eqId, new Timestamp(startTime), new Timestamp(endTime), height);
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(eqId, new Timestamp(startTime), new Timestamp(endTime), height);
         BigDecimal zero = new BigDecimal(0);
         List<Map<String, Object>> list = new ArrayList<>();
         for (WindDirectionEnum value : WindDirectionEnum.values()) {
@@ -781,9 +781,9 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      */
     public List<Map<String, Object>> getWindEnergyDensity(Long startTime, Long endTime, String eqId, String height) {
         //查询风速数据
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWdAveAndWdAveAndWsStaForHeight(eqId, new Timestamp(startTime), new Timestamp(endTime), height);
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWdAveAndWdAveAndWsStaForHeight(eqId, new Timestamp(startTime), new Timestamp(endTime), height);
         //查询空气密度
-        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataMapper.selectAir(eqId, new Timestamp(startTime), new Timestamp(endTime));
+        List<ProphaseWeatherData> prophaseWeatherDataList = prophaseWeatherDataService.selectAir(eqId, new Timestamp(startTime), new Timestamp(endTime));
 
         List<Map<String, Object>> list = new ArrayList<>();
         for (WindDirectionEnum value : WindDirectionEnum.values()) {
@@ -819,7 +819,7 @@ public class RealTimeDisplayServiceImpl implements RealTimeDisplayService {
      * @throws Exception
      */
     public List queryCharts(Long startTime, Long endTime, String equipmentId, String height) {
-        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataMapper.selectWdAveForHeight(equipmentId, new Timestamp(startTime), new Timestamp(endTime), height);
+        List<ProphaseAnemometryData> prophaseAnemometryDataList = prophaseAnemometryDataService.selectWdAveForHeight(equipmentId, new Timestamp(startTime), new Timestamp(endTime), height);
 
         List list = new ArrayList();
         BigDecimal total = BigDecimal.ZERO;

+ 8 - 6
neim-biz/src/main/java/com/jiayue/biz/service/impl/WindTowerDataParentTableServiceImpl.java

@@ -14,6 +14,8 @@ import com.jiayue.biz.domain.*;
 import com.jiayue.biz.mapper.ProphaseAnemometryDataMapper;
 import com.jiayue.biz.mapper.ProphaseWeatherDataMapper;
 import com.jiayue.biz.mapper.WindTowerDataParentTableMapper;
+import com.jiayue.biz.service.ProphaseAnemometryDataService;
+import com.jiayue.biz.service.ProphaseWeatherDataService;
 import com.jiayue.biz.service.WindTowerDataChildTableService;
 import com.jiayue.biz.service.WindTowerDataParentTableService;
 import com.jiayue.biz.util.CalculationUtil;
@@ -60,10 +62,10 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
     DisplayConfigServiceImpl displayConfigService;
 
     @Autowired
-    ProphaseAnemometryDataMapper prophaseAnemometryDataMapper;
+    ProphaseAnemometryDataService prophaseAnemometryDataService;
 
     @Autowired
-    ProphaseWeatherDataMapper prophaseWeatherDataMapper;
+    ProphaseWeatherDataService prophaseWeatherDataService;
 
 
     /**
@@ -129,7 +131,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
                             log.error("时间转换异常:" + e);
                         }
                     }
-                    prophaseAnemometryDataMapper.insertOneWithNew(one);
+                    prophaseAnemometryDataService.insertOneWithNew(one);
                 }
 
 //                log.error("prophaseAnemometryDataArrayList = " + JSONUtil.toJsonPrettyStr(prophaseAnemometryDataArrayList));
@@ -186,7 +188,7 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
 
             }
 //            log.error("prophaseAnemometryPublicDataArrayList = " + JSONUtil.toJsonPrettyStr(prophaseAnemometryPublicDataArrayList));
-            prophaseWeatherDataMapper.insertSplice(prophaseAnemometryPublicDataArrayList, equipmentId);
+            prophaseWeatherDataService.insertSplice(prophaseAnemometryPublicDataArrayList, equipmentId);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -651,8 +653,8 @@ public class WindTowerDataParentTableServiceImpl extends ServiceImpl<WindTowerDa
         //获取测风塔数据
         List<WindTowerInfo> list = windTowerInfoService.lambdaQuery().eq(WindTowerInfo::getEquipmentNo, equipmentId).list();
         List<Map<String, Object>> mapList = new ArrayList<>();
-        List<ProphaseAnemometryData> prophaseAnemometryPublicData = prophaseAnemometryDataMapper.selectList(lambdaQueryWrapper);
-        List<ProphaseWeatherData> prophaseAnemometryPublicDataList = prophaseWeatherDataMapper.selectPublicData(equipmentId, startTime, endTime);
+        List<ProphaseAnemometryData> prophaseAnemometryPublicData = prophaseAnemometryDataService.list(lambdaQueryWrapper);
+        List<ProphaseWeatherData> prophaseAnemometryPublicDataList = prophaseWeatherDataService.selectPublicData(equipmentId, startTime, endTime);
 
         String heights = list.get(0).getHeights();
         String wdHeights = list.get(0).getWdHeights();