leecode,rt_phm更新更新

This commit is contained in:
kevinding1125 2023-05-28 18:13:04 +08:00
parent c9f5e14e63
commit 35ecb5b9c8
16 changed files with 385 additions and 39 deletions

View File

@ -16,7 +16,7 @@ import org.springframework.context.annotation.ComponentScan;
*/ */
@SpringBootApplication @SpringBootApplication
@EnableFeignClients @EnableFeignClients
@MapperScan(basePackages = {"com.cqu.dataInterface"}) @ComponentScan(basePackages = {"com.cqu"})
public class DataInterfaceApplication { public class DataInterfaceApplication {
public static void main(String[] args) { public static void main(String[] args) {

View File

@ -0,0 +1,42 @@
package com.cqu.dataInterface.controller;
import com.cqu.dataInterface.entity.GasTypeState;
import com.cqu.dataInterface.service.GasService;
import com.cqu.dataInterface.utils.TimeUtils;
import com.cqu.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.controller
*@Author: markilue
*@CreateTime: 2023-05-28 15:51
*@Description: TODO 燃机Controller层
*@Version: 1.0
*/
@RestController
@RequestMapping("/api/dataInterface/gas")
public class GasController {
@Autowired
private GasService gasService;
@GetMapping("/gasTypeState/{date}/{limit}")
public Result getGasTypeStateByTm(@PathVariable(required = false) String date, @PathVariable(required = false) Integer limit) {
if ("".equals(date)) {
date = TimeUtils.getCurrentDate();
}
List<GasTypeState> gasTypeStateList = gasService.getGasTypeStateByTm(date, limit);
return Result.ok().data("data", gasTypeStateList);
}
}

View File

@ -1,14 +1,15 @@
package com.cqu.dataInterface.controller; package com.cqu.dataInterface.controller;
import com.cqu.dataInterface.entity.WindSCADALocationState; import com.cqu.dataInterface.entity.WindSCADALocationState;
import com.cqu.dataInterface.entity.WindSCADATypeState;
import com.cqu.dataInterface.service.WindSCADAService; import com.cqu.dataInterface.service.WindSCADAService;
import com.cqu.dataInterface.utils.TimeUtils;
import com.cqu.utils.Result; import com.cqu.utils.Result;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.sql.Time;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -28,20 +29,28 @@ public class WindSCADAController {
@Autowired @Autowired
private WindSCADAService windSCADAService; private WindSCADAService windSCADAService;
@RequestMapping("/windSCADALocationState") @GetMapping("/windSCADALocationState/{date}/{limit}")
public Result getWindSCADALocationState(@RequestParam(value = "date", defaultValue = "0") String date, @RequestParam(value = "limit", defaultValue = "5") Integer limit) { public Result getWindSCADALocationState(@PathVariable(required = false) String date, @PathVariable(required = false) Integer limit) {
if ("0".equals(date)) { if ("".equals(date)) {
date = getCurrentDate(); date = TimeUtils.getCurrentDate();
} }
List<WindSCADALocationState> locationStateList = windSCADAService.getWindSCADALocationStateByTm(date, limit); List<WindSCADALocationState> locationStateList = windSCADAService.getWindSCADALocationStateByTm(date, limit);
return Result.ok().data("data", locationStateList); return Result.ok().data("data", locationStateList);
} }
@GetMapping("/windSCADATypeState/{date}/{limit}")
public Result getWindSCADATypeState(@PathVariable(required = false) String date, @PathVariable(required = false) Integer limit) {
if ("".equals(date)) {
date = TimeUtils.getCurrentDate();
}
List<WindSCADATypeState> locationStateList = windSCADAService.getWindSCADATypeStateByTm(date, limit);
public String getCurrentDate() { return Result.ok().data("data", locationStateList);
return DateFormatUtils.format(new Date(), "yyyyMMdd");
} }
} }

View File

@ -0,0 +1,41 @@
package com.cqu.dataInterface.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.entity
*@Author: markilue
*@CreateTime: 2023-05-28 15:45
*@Description: TODO 燃机聚合数据实体类
*@Version: 1.0
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GasTypeState {
String stt;
String edt;
String type_id;
Long rated_temp;
Long rated_press;
Long rated_flow_rate;
Long rated_speed;
Long rated_power;
Long rated_load;
Long rated_duration;
Double avg_LubeReturnT2;
Double avg_T5TC1;
Double avg_GFFlow;
Double avg_LFFlow;
Double avg_NHP_1;
Double avg_AirInletDP_1;
Double avg_T1_1;
Double avg_LubeHaderP;
Double avg_LubeFilterDP;
Double avg_TankT;
Double avg_GrBxAccel;
}

View File

@ -1,9 +1,13 @@
package com.cqu.dataInterface.entity; package com.cqu.dataInterface.entity;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/** /**
*@BelongsProject: phm_parent *@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.entity *@BelongsPackage: com.cqu.dataInterface.entity
@ -13,6 +17,7 @@ import lombok.NoArgsConstructor;
*@Version: 1.0 *@Version: 1.0
*/ */
@Data @Data
@Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class WindSCADALocationState { public class WindSCADALocationState {
@ -25,25 +30,44 @@ public class WindSCADALocationState {
private String location; private String location;
private String longitude; private String longitude;
private String latitude; private String latitude;
private Double production; private BigDecimal production;
private Double avg_torque; @Builder.Default
private Double avg_sumptemp; private BigDecimal avg_torque = BigDecimal.ZERO;
private Double avg_inletoiltemp; @Builder.Default
private Double avg_winddirection;
private Double avg_envtemp; private BigDecimal avg_sumptemp = BigDecimal.ZERO;
private Double avg_gen_speed; @Builder.Default
private Double avg_pumpoutletpress; private BigDecimal avg_inletoiltemp = BigDecimal.ZERO;
private Double avg_engineroom_temp; @Builder.Default
private Double avg_rotorspeed; private BigDecimal avg_winddirection = BigDecimal.ZERO;
private Double avg_activepower; @Builder.Default
private Double avg_engineroom_vibration_x; private BigDecimal avg_envtemp = BigDecimal.ZERO;
private Double avg_engineroom_vibration_y; @Builder.Default
private Double avg_highspeedshaft_front_temp; private BigDecimal avg_gen_speed = BigDecimal.ZERO;
private Double avg_max_windingtemp; @Builder.Default
private Double avg_highspeedshaft_rear_temp; private BigDecimal avg_pumpoutletpress = BigDecimal.ZERO;
private Double avg_windspeed; @Builder.Default
private Double avg_coolingwatertemp; private BigDecimal avg_engineroom_temp = BigDecimal.ZERO;
private Double avg_inletpress; @Builder.Default
private BigDecimal avg_rotorspeed = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_activepower = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_engineroom_vibration_x = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_engineroom_vibration_y = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_highspeedshaft_front_temp = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_max_windingtemp = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_highspeedshaft_rear_temp = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_windspeed = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_coolingwatertemp = BigDecimal.ZERO;
@Builder.Default
private BigDecimal avg_inletpress = BigDecimal.ZERO;
private Long ts; private Long ts;
} }

View File

@ -0,0 +1,50 @@
package com.cqu.dataInterface.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.warehouse.realtime.entity
*@Author: markilue
*@CreateTime: 2023-05-25 21:39
*@Description: TODO 风电SCADA数据按照地区聚合后的对象
*@Version: 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WindSCADATypeState {
//TODO 注意:这些属性名和类型必须和建表的时候完全对应上,ts字段为Long类型BigInt ->Long
private String stt;
private String edt;
private String type_id;
private Long rated_efficiency;
private Long rated_load;
private Long rated_power;
private Long rated_speed;
private Long rated_air_volume;
private BigDecimal avg_torque;
private BigDecimal avg_sumptemp;
private BigDecimal avg_inletoiltemp;
private BigDecimal avg_winddirection;
private BigDecimal avg_envtemp;
private BigDecimal avg_gen_speed;
private BigDecimal avg_pumpoutletpress;
private BigDecimal avg_engineroom_temp;
private BigDecimal avg_rotorspeed;
private BigDecimal avg_activepower;
private BigDecimal avg_engineroom_vibration_x;
private BigDecimal avg_engineroom_vibration_y;
private BigDecimal avg_highspeedshaft_front_temp;
private BigDecimal avg_max_windingtemp;
private BigDecimal avg_highspeedshaft_rear_temp;
private BigDecimal avg_windspeed;
private BigDecimal avg_coolingwatertemp;
private BigDecimal avg_inletpress;
private Long ts;
}

View File

@ -0,0 +1,31 @@
package com.cqu.dataInterface.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.cqu.dataInterface.entity.GasTypeState;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.mapper
*@Author: markilue
*@CreateTime: 2023-05-28 15:46
*@Description: TODO 燃机Mapper
*@Version: 1.0
*/
@Mapper
@DS("clickhouse")
public interface GasMapper {
@Select("select * " +
"from gas_type_state " +
"where " +
" toYYYYMMDD(stt) =#{tm} " +
"limit #{limit}")
@DS("clickhouse")
List<GasTypeState> selectGasTypeStateByTm(@Param("tm") String tm, @Param("limit") Integer limit);
}

View File

@ -2,6 +2,8 @@ package com.cqu.dataInterface.mapper;
import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.annotation.DS;
import com.cqu.dataInterface.entity.WindSCADALocationState; import com.cqu.dataInterface.entity.WindSCADALocationState;
import com.cqu.dataInterface.entity.WindSCADATypeState;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
@ -16,14 +18,45 @@ import java.util.List;
*@Version: 1.0 *@Version: 1.0
*/ */
@DS("clickhouse") //本个mapper默认的数据源 @DS("clickhouse") //本个mapper默认的数据源
@Mapper
public interface WindSCADAMapper { public interface WindSCADAMapper {
@Select("select stt, " +
" edt, " +
" windfarm, " +
" location, " +
" longitude, " +
" latitude, " +
" production, " +
" avg_torque, " +
" avg_sumptemp, " +
" avg_inletoiltemp, " +
" avg_winddirection, " +
" avg_envtemp, " +
" avg_gen_speed, " +
" avg_pumpoutletpress, " +
" avg_engineroom_temp, " +
" avg_rotorspeed, " +
" avg_activepower, " +
" avg_engineroom_vibration_x, " +
" avg_engineroom_vibration_y, " +
" avg_highspeedshaft_front_temp, " +
" avg_max_windingtemp, " +
" avg_highspeedshaft_rear_temp, " +
" avg_windspeed, " +
" avg_coolingwatertemp, " +
" avg_inletpress, " +
" ts " +
"from wind_SCADA_location_state " +
"where toYYYYMMDD(stt) = #{tm} limit #{limit}")
@DS("clickhouse")
List<WindSCADALocationState> selectWindSCADALocationStateByTm(@Param("tm") String tm, @Param("limit") Integer limit);//通过tm查询风电SCADA数据根据地区聚合之后的数据
@Select("select * " + @Select("select * " +
" " +
"from wind_SCADA_type_state " + "from wind_SCADA_type_state " +
"where " + "where " +
" toYYYYMMDD(ts) = ${tm} " + " toYYYYMMDD(stt) = #{tm} " +
"and limit ${limit}") "limit #{limit}")
@DS("clickhouse") List<WindSCADATypeState> selectWindSCADATypeStateByTm(@Param("tm") String tm, @Param("limit") Integer limit);//通过tm查询风电SCADA数据根据地区聚合之后的数据
List<WindSCADALocationState> selectWindSCADALocationStateByTm(@Param("tm") String tm,@Param("limit") Integer limit);//通过tm查询风电SCADA数据根据地区聚合之后的数据
} }

View File

@ -1,7 +1,36 @@
-- 按照tm查询风电SCADA数据按照地区聚合之后的结果 -- 按照tm查询风电SCADA数据按照地区聚合之后的结果
-- 注意:需要把所有名称都写出来,按顺序 否则映射不上,需要注意Mybatis-plus的是否转驼峰的配置
select stt,
edt,
windfarm,
location,
longitude,
latitude,
production,
avg_torque,
avg_sumptemp,
avg_inletoiltemp,
avg_winddirection,
avg_envtemp,
avg_gen_speed,
avg_pumpoutletpress,
avg_engineroom_temp,
avg_rotorspeed,
avg_activepower,
avg_engineroom_vibration_x,
avg_engineroom_vibration_y,
avg_highspeedshaft_front_temp,
avg_max_windingtemp,
avg_highspeedshaft_rear_temp,
avg_windspeed,
avg_coolingwatertemp,
avg_inletpress,
ts
from wind_SCADA_location_state
where toYYYYMMDD(stt) = 20180730 limit 5
select * select *
from wind_SCADA_type_state from wind_SCADA_type_state
where where
toYYYYMMDD(ts) =tm toYYYYMMDD(stt) =20180730
and limit 5 limit 5

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cqu.dataInterface.mapper.GasMapper">
</mapper>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cqu.dataInterface.mapper.WindSCADAMapper">
</mapper>

View File

@ -0,0 +1,19 @@
package com.cqu.dataInterface.service;
import com.cqu.dataInterface.entity.GasTypeState;
import java.util.List;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.service
*@Author: markilue
*@CreateTime: 2023-05-28 15:48
*@Description: TODO 燃机service类
*@Version: 1.0
*/
public interface GasService {
List<GasTypeState> getGasTypeStateByTm(String date, Integer limit);
}

View File

@ -1,6 +1,7 @@
package com.cqu.dataInterface.service; package com.cqu.dataInterface.service;
import com.cqu.dataInterface.entity.WindSCADALocationState; import com.cqu.dataInterface.entity.WindSCADALocationState;
import com.cqu.dataInterface.entity.WindSCADATypeState;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -17,4 +18,6 @@ public interface WindSCADAService {
List<WindSCADALocationState> getWindSCADALocationStateByTm(String tm,Integer limit); List<WindSCADALocationState> getWindSCADALocationStateByTm(String tm,Integer limit);
List<WindSCADATypeState> getWindSCADATypeStateByTm(String tm, Integer limit);
} }

View File

@ -0,0 +1,29 @@
package com.cqu.dataInterface.service.impl;
import com.cqu.dataInterface.entity.GasTypeState;
import com.cqu.dataInterface.mapper.GasMapper;
import com.cqu.dataInterface.service.GasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.service.impl
*@Author: markilue
*@CreateTime: 2023-05-28 15:50
*@Description: TODO 燃机服务实现类
*@Version: 1.0
*/
@Service
public class GasServiceImpl implements GasService {
@Autowired
private GasMapper gasMapper;
@Override
public List<GasTypeState> getGasTypeStateByTm(String date, Integer limit) {
return gasMapper.selectGasTypeStateByTm(date, limit);
}
}

View File

@ -1,6 +1,7 @@
package com.cqu.dataInterface.service.impl; package com.cqu.dataInterface.service.impl;
import com.cqu.dataInterface.entity.WindSCADALocationState; import com.cqu.dataInterface.entity.WindSCADALocationState;
import com.cqu.dataInterface.entity.WindSCADATypeState;
import com.cqu.dataInterface.mapper.WindSCADAMapper; import com.cqu.dataInterface.mapper.WindSCADAMapper;
import com.cqu.dataInterface.service.WindSCADAService; import com.cqu.dataInterface.service.WindSCADAService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -27,4 +28,9 @@ public class WindSCADAServiceImpl implements WindSCADAService {
public List<WindSCADALocationState> getWindSCADALocationStateByTm(String tm, Integer limit) { public List<WindSCADALocationState> getWindSCADALocationStateByTm(String tm, Integer limit) {
return windSCADAMapper.selectWindSCADALocationStateByTm(tm, limit); return windSCADAMapper.selectWindSCADALocationStateByTm(tm, limit);
} }
@Override
public List<WindSCADATypeState> getWindSCADATypeStateByTm(String tm, Integer limit) {
return windSCADAMapper.selectWindSCADATypeStateByTm(tm, limit);
}
} }

View File

@ -0,0 +1,20 @@
package com.cqu.dataInterface.utils;
import org.apache.commons.lang3.time.DateFormatUtils;
import java.util.Date;
/**
*@BelongsProject: phm_parent
*@BelongsPackage: com.cqu.dataInterface.utils
*@Author: markilue
*@CreateTime: 2023-05-28 15:56
*@Description: TODO 时间工具类
*@Version: 1.0
*/
public class TimeUtils {
public static String getCurrentDate() {
return DateFormatUtils.format(new Date(), "yyyyMMdd");
}
}