Commit a0d77385 authored by tangwei's avatar tangwei

新增定时获取发电量参数

parent 3a7d9421
...@@ -19,19 +19,58 @@ import java.util.Date; ...@@ -19,19 +19,58 @@ import java.util.Date;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Document(indexName = "jxiop_dailyPowerGeneration") @Document(indexName = "jxiop_dailyPowerGeneration")
public class ESDailyPowerGeneration extends ESEquipments { public class ESDailyPowerGeneration {
@Id
private String id;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String stationType;//场站类型 private String stationId;
//场站名称
@Field(type = FieldType.Text )
private String stationName;
//场站类型
@Field(type = FieldType.Text )
private String stationType;
//所属省份
@Field(type = FieldType.Text )
private String belongProvince;
//所属片区
@Field(type = FieldType.Text )
private String belongArea;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String day;//时间标识 private String day;//时间标识
@Field(type = FieldType.Keyword)
private String gatewayId;
@Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = false)
private Date createdTime;
@Field(type = FieldType.Double, index = false)
private Double value;
@Field(type = FieldType.Keyword )
private String equipmentIndexName;
@Field(type = FieldType.Keyword )
private String equipmentNumber;
@Field(type = FieldType.Text, index = false)
private String address;
public ESDailyPowerGeneration(String id, String stationId, String stationName, String stationType, String belongProvince, String belongArea, String day, String gatewayId, Date createdTime, Double value, String equipmentIndexName, String equipmentNumber, String address) {
this.id = id;
this.stationId = stationId;
this.stationName = stationName;
this.stationType = stationType;
this.belongProvince = belongProvince;
this.belongArea = belongArea;
this.day = day;
this.gatewayId = gatewayId;
this.createdTime = createdTime;
this.value = value;
this.equipmentIndexName = equipmentIndexName;
this.equipmentNumber = equipmentNumber;
this.address = address;
}
public ESDailyPowerGeneration() {
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.ESDto; package com.yeejoin.amos.boot.module.jxiop.biz.ESDto;
import io.github.classgraph.json.Id;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -14,12 +18,59 @@ import org.springframework.data.elasticsearch.annotations.FieldType; ...@@ -14,12 +18,59 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Document(indexName = "jxiop_moonPowerGeneration") @Document(indexName = "jxiop_moonPowerGeneration")
public class ESMoonPowerGeneration extends ESEquipments{ public class ESMoonPowerGeneration {
@Id
private String id;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String stationType;//场站类型 private String stationId;
//场站名称
@Field(type = FieldType.Text )
private String stationName;
//场站类型
@Field(type = FieldType.Text )
private String stationType;
//所属省份
@Field(type = FieldType.Text )
private String belongProvince;
//所属片区
@Field(type = FieldType.Text )
private String belongArea;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String day;//时间标识 private String day;//时间标识
@Field(type = FieldType.Keyword)
private String gatewayId;
@Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = false)
private Date createdTime;
@Field(type = FieldType.Double, index = false)
private Double value;
@Field(type = FieldType.Keyword )
private String equipmentIndexName;
@Field(type = FieldType.Keyword )
private String equipmentNumber;
@Field(type = FieldType.Text, index = false)
private String address;
public ESMoonPowerGeneration(String id, String stationId, String stationName, String stationType, String belongProvince, String belongArea, String day, String gatewayId, Date createdTime, Double value, String equipmentIndexName, String equipmentNumber, String address) {
this.id = id;
this.stationId = stationId;
this.stationName = stationName;
this.stationType = stationType;
this.belongProvince = belongProvince;
this.belongArea = belongArea;
this.day = day;
this.gatewayId = gatewayId;
this.createdTime = createdTime;
this.value = value;
this.equipmentIndexName = equipmentIndexName;
this.equipmentNumber = equipmentNumber;
this.address = address;
}
public ESMoonPowerGeneration() {
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.ESDto; package com.yeejoin.amos.boot.module.jxiop.biz.ESDto;
import io.github.classgraph.json.Id;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.annotations.FieldType;
import java.util.Date;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -15,12 +19,58 @@ import org.springframework.data.elasticsearch.annotations.FieldType; ...@@ -15,12 +19,58 @@ import org.springframework.data.elasticsearch.annotations.FieldType;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@Document(indexName = "jxiop_yearPowerGeneration") @Document(indexName = "jxiop_yearPowerGeneration")
public class ESYearPowerGeneration extends ESEquipments{ public class ESYearPowerGeneration {
@Id
private String id;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String stationType;//场站类型 private String stationId;
//场站名称
@Field(type = FieldType.Text )
private String stationName;
//场站类型
@Field(type = FieldType.Text )
private String stationType;
//所属省份
@Field(type = FieldType.Text )
private String belongProvince;
//所属片区
@Field(type = FieldType.Text )
private String belongArea;
@Field(type = FieldType.Keyword ) @Field(type = FieldType.Keyword )
private String day;//时间标识 private String day;//时间标识
@Field(type = FieldType.Keyword)
private String gatewayId;
@Field(type = FieldType.Date, format = DateFormat.basic_date_time, index = false)
private Date createdTime;
@Field(type = FieldType.Double, index = false)
private Double value;
@Field(type = FieldType.Keyword )
private String equipmentIndexName;
@Field(type = FieldType.Keyword )
private String equipmentNumber;
@Field(type = FieldType.Text, index = false)
private String address;
public ESYearPowerGeneration(String id, String stationId, String stationName, String stationType, String belongProvince, String belongArea, String day, String gatewayId, Date createdTime, Double value, String equipmentIndexName, String equipmentNumber, String address) {
this.id = id;
this.stationId = stationId;
this.stationName = stationName;
this.stationType = stationType;
this.belongProvince = belongProvince;
this.belongArea = belongArea;
this.day = day;
this.gatewayId = gatewayId;
this.createdTime = createdTime;
this.value = value;
this.equipmentIndexName = equipmentIndexName;
this.equipmentNumber = equipmentNumber;
this.address = address;
}
public ESYearPowerGeneration() {
}
} }
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESDailyPowerGenerationRepository extends PagingAndSortingRepository<ESDailyPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESMoonPowerGenerationRepository extends PagingAndSortingRepository<ESMoonPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.repository;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESYearPowerGeneration;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
/**
* @description:
* @author: tw
* @createDate: 2023/8/9
*/
@Repository
public interface ESYearPowerGenerationRepository extends PagingAndSortingRepository<ESYearPowerGeneration, String> {
}
package com.yeejoin.amos.boot.module.jxiop.biz.scheduled; package com.yeejoin.amos.boot.module.jxiop.biz.scheduled;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESDailyPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESMoonPowerGeneration;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.StationCacheInfoDto;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PowerGenerationImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
/** /**
* @description: * @description:
* @author: tw * @author: tw
* @createDate: 2023/8/9 * @createDate: 2023/8/9
*/ */
@Component
@EnableScheduling
public class PowerGeneration { public class PowerGeneration {
@Autowired
PowerGenerationImpl powerGenerationImpl;
private final String dayvalue="日发电量";
private final String moonValue="月发电量";
private final String yearValue="年发电量";
private final String dayDateFormat="YYYY-MM-DD";
private final String moonDateFormat="YYYY-MM";
private final String yearDateFormat="YYYY";
private final String dayType="day";
private final String moonType="moon";
private final String yearType="year";
//定时更新日发电量
@Scheduled(cron = "${daily.power.generation.cron}")
public void addESDailyPowerGeneration(){
List<StationCacheInfoDto> list =new ArrayList<>();
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), dayvalue, dayDateFormat, dayType);
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getBoosterGatewayId(), dayvalue, dayDateFormat, dayType);
}
}
//定时更新月发电量
@Scheduled(cron = "${moon.power.generation.cron}")
public void addESMoonPowerGeneration(){
List<StationCacheInfoDto> list =new ArrayList<>();
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), moonValue, moonDateFormat, moonType);
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getBoosterGatewayId(), moonValue, moonDateFormat, moonType);
}
}
//定时更新年发电量
@Scheduled(cron = "${year.power.generation.cron}")
public void addESYearPowerGeneration(){
List<StationCacheInfoDto> list =new ArrayList<>();
for (StationCacheInfoDto stationCacheInfoDto : list) {
//风机
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getFanGatewayId(), yearValue, yearDateFormat, yearType);
//光伏
powerGenerationImpl.addPowerGeneration( stationCacheInfoDto, stationCacheInfoDto.getBoosterGatewayId(), yearValue, yearDateFormat, yearType);
}
}
} }
## DB properties: ## DB properties:
## db1-production database ## db1-production database
spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db1.datasource.url=jdbc:mysql://139.9.173.44:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.db1.datasource.url=jdbc:mysql://39.98.224.23:3306/production?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.username=root spring.db1.datasource.username=root
spring.db1.datasource.password=Yeejoin@2020 spring.db1.datasource.password=Yeejoin@2020
spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver spring.db1.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
## db2-sync_data ## db2-sync_data
spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db2.datasource.url=jdbc:mysql://139.9.173.44:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8 spring.db2.datasource.url=jdbc:mysql://39.98.224.23:3306/jxiop_sync_data?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020 spring.db2.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver spring.db2.datasource.driver-class-name: com.mysql.cj.jdbc.Driver
...@@ -84,7 +84,7 @@ emqx.max-inflight=1000 ...@@ -84,7 +84,7 @@ emqx.max-inflight=1000
#spring.influx.bufferLimit=20000 #spring.influx.bufferLimit=20000
spring.influx.url=http://139.9.173.44:18086 spring.influx.url=http://39.98.224.23:8086
spring.influx.password=Yeejoin@2020 spring.influx.password=Yeejoin@2020
spring.influx.user=root spring.influx.user=root
spring.influx.database=iot_platform spring.influx.database=iot_platform
...@@ -124,3 +124,18 @@ myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness ...@@ -124,3 +124,18 @@ myqueue=amos.privilege.v1.JXIOP.AQSC_FDGL.userBusiness
fan.statuts.stattuspath=upload/jxiop/device_status fan.statuts.stattuspath=upload/jxiop/device_status
pictureUrl=upload/jxiop/syz/ pictureUrl=upload/jxiop/syz/
daily.power.generation.cron=* * */10 * * ?
moon.power.generation.cron=* * */10 * * ?
year.power.generation.cron=* * */10 * * ?
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