Commit 60f881c8 authored by chenzhao's avatar chenzhao

Merge remote-tracking branch 'origin/developer' into developer

parents 9aacd689 d9661f86
......@@ -58,6 +58,7 @@
<artifactId>tyboot-component-emq</artifactId>
<version>${tyboot-version}</version>
</dependency>
<!--
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-event</artifactId>
......@@ -69,6 +70,7 @@
</exclusion>
</exclusions>
</dependency>
-->
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-component-opendata</artifactId>
......
......@@ -5,23 +5,21 @@ import java.net.InetAddress;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
/**
*
* <pre>
......@@ -41,10 +39,13 @@ import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
@EnableScheduling
@MapperScan(value = { "org.typroject.tyboot.*.*.face.orm.dao", "com.yeejoin.amos.api.*.face.orm.dao",
"org.typroject.tyboot.face.*.orm.dao*", "com.yeejoin.amos.boot.biz.common.dao.mapper" })
@ComponentScan({ "org.typroject", "com.yeejoin.amos" })
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class})
@ComponentScan(value = { "org.typroject",
"com.yeejoin.amos" }, excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.typroject.tyboot.component.event"))
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class })
public class HousevPVapiApplication {
private static final Logger logger = LogManager.getLogger(HousevPVapiApplication.class);
public static void main(String[] args) throws Exception {
// 服务启动
ConfigurableApplicationContext context = SpringApplication.run(HousevPVapiApplication.class, args);
......
......@@ -126,7 +126,7 @@ public class GolangRequestUtil {
}
housepvapiRecords.setResponse(respone);
// housepvapiRecordsMapper.insert(housepvapiRecords);
log.info("锦浪云数据请求详情:"+JSONObject.toJSONString(housepvapiRecords));
//log.info("锦浪云数据请求详情:"+JSONObject.toJSONString(housepvapiRecords));
return respone;
}
......
......@@ -70,7 +70,7 @@ public class KsolarRequestUtil {
String url = KSolarConstant.baseurl + apiurl;
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
log.info("原始数据:{}", jsonArray);
//log.info("原始数据:{}", jsonArray);
if (!ObjectUtils.isEmpty(jsonArray)) {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
}
......@@ -134,7 +134,7 @@ public class KsolarRequestUtil {
}
housepvapiRecords.setResponse(respone);
// housepvapiRecordsMapper.insert(housepvapiRecords);
log.info("科士达数据请求详情:"+JSONObject.toJSONString(housepvapiRecords));
//log.info("科士达数据请求详情:"+JSONObject.toJSONString(housepvapiRecords));
return respone;
}
......
......@@ -116,7 +116,14 @@ public class SunlightUtil {
{
put("1", "在线");
put("0", "离线");
put("2","报警" );
}
};
public static final HashMap<String, String> gzzt= new HashMap<String, String>() {
{
put("1", "故障");
put("2", "报警");
put("4", "正常" );
}
};
......
......@@ -19,7 +19,7 @@ public class ImasterInverterListDetails {
Double mppt_total_cap ;
Double pv24_i ;
Double pv8_u ;
Double open_time ;
String open_time ;
Double pv22_u ;
Double a_i ;
Double pv24_u ;
......@@ -43,7 +43,7 @@ public class ImasterInverterListDetails {
Double mppt_power ;
Double pv13_u ;
int run_state ;
Double close_time ;
String close_time ;
Double pv19_i ;
Double mppt_7_cap ;
Double mppt_5_cap ;
......
......@@ -22,13 +22,17 @@ import com.yeejoin.amos.api.householdapi.face.service.ImasterDataService;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -117,9 +121,16 @@ public class ImasterDataServiceImpl implements ImasterDataService {
@Autowired
TdJpStationMapper tdJpStationMapper;
final static Logger logger = LoggerFactory.getLogger(GoLangDataAcquisitionServiceImpl.class);
final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Scheduled(cron = "${dataRequstScheduled.huawei}")
@Override
@Async
public void stationList() {
long ts = System.currentTimeMillis();
logger.info("-------华为同步电站开始" + ts + "------- " + sdf.format(new Date()));
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("pageNo", 1);
String requestParaminfo = JSON.toJSONString(requestInfo);
......@@ -134,13 +145,16 @@ public class ImasterDataServiceImpl implements ImasterDataService {
imasterStationList.setCreatedTime(System.currentTimeMillis());
imasterStationMapper.insert(imasterStationList);
}
logger.info("-------华为同步电站结束" + ts + "------- " + sdf.format(new Date()));
}
@Scheduled(cron = "${dataRequstScheduled.huawei}")
@Override
@Async
public void stationDetail() {
long ts = System.currentTimeMillis();
logger.info("-------华为同步电站详情开始" + ts + "------- " + sdf.format(new Date()));
List<String> stationList = imasterStationMapper.getStationIds();
String today = DateUtil.today();
String hour = new Date().getHours() + ":00";
......@@ -456,12 +470,16 @@ public class ImasterDataServiceImpl implements ImasterDataService {
}
}
this.inverterDetail(result4);
logger.info("-------华为同步电站详情结束" + ts + "------- " + sdf.format(new Date()));
}
@Scheduled(cron = "${dataRequstScheduled.huawei}")
@Override
@Async
public void collectorList() {
long ts = System.currentTimeMillis();
logger.info("-------华为同步采集器/逆变器开始" + ts + "------- " + sdf.format(new Date()));
List<String> stationIds = imasterStationMapper.getStationIds();
// try {
// TimeUnit.SECONDS.sleep(1);
......@@ -547,6 +565,7 @@ public class ImasterDataServiceImpl implements ImasterDataService {
this.inverterList(result);
logger.info("-------华为同步采集器/逆变器结束" + ts + "------- " + sdf.format(new Date()));
}
@Override
......@@ -1017,8 +1036,10 @@ public class ImasterDataServiceImpl implements ImasterDataService {
@Scheduled(cron = "${dataRequstScheduled.huawei}")
@Override
@Async
public void inverAlramInfo() {
long ts = System.currentTimeMillis();
logger.info("-------华为同步告警开始" + ts + "------- " + sdf.format(new Date()));
List<String> inverterSns = imasterInverterListMapper.getCollectIds();
// for (int i = 0; i < inverterSns.size(); i++) {
// try {
......@@ -1087,5 +1108,6 @@ public class ImasterDataServiceImpl implements ImasterDataService {
}
}
// }
logger.info("-------华为同步告警结束" + ts + "------- " + sdf.format(new Date()));
}
}
......@@ -112,7 +112,6 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
@Override
@Scheduled(cron = "${dataRequstScheduled.Sofar}")
@PostConstruct
public void stationList() {
Map<String, Object> requestInfo = new HashMap<>();
requestInfo.put("page", 1);
......@@ -1199,15 +1198,15 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
requestInfo.put("stationId", jpStation.getThirdStationId());
if (jpStation.getThirdStationId().equals("517021808701218816")){
System.out.println("6666666666666666666666666");
}
// if (jpStation.getThirdStationId().equals("517021808701218816")){
// System.out.println("6666666666666666666666666");
// }
String param = JSON.toJSONString(requestInfo);
List<SofarWarm> jsonObject2 = requestUtil.getResPonse(SoFarConstant.alert, SoFarConstant.requestPost, param,
SoFarConstant.stationAlertItems, SofarWarm.class);
if (jsonObject2 != null && jsonObject2.size() > 0) {
System.out.println("88888888888888888888888");
}
// if (jsonObject2 != null && jsonObject2.size() > 0) {
// System.out.println("88888888888888888888888");
// }
for (SofarWarm sofarWarm : jsonObject2) {
if (sofarWarm.getDeviceType().equals("INVERTER") || sofarWarm.getDeviceType().equals("COLLECTOR")) {
HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn();
......
package com.yeejoin.amos.config;
import java.lang.reflect.Method;
import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import com.yeejoin.amos.HousevPVapiApplication;
@EnableAsync
@Configuration
@Primary
public class ListenerAsyncConfiguration implements AsyncConfigurer {
private static final Logger logger = LogManager.getLogger(ListenerAsyncConfiguration.class);
/**
* 用于@Async注解获取默认线程连接池
*
* @return
*/
@Override
public Executor getAsyncExecutor() {
// 此类由Spring提供,org.springframework.scheduling.concurrent包下,是线程池的封装类
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
// 线程池中线程的名字前缀
taskExecutor.setThreadNamePrefix("taskThreadPool-async-");
// 线程池核心线程数量
taskExecutor.setCorePoolSize(20);
// 线程池最大线程数量
taskExecutor.setMaxPoolSize(50);
// 线程池空闲线程存活时间,单位秒
taskExecutor.setKeepAliveSeconds(100);
// 线程池拒绝策略
taskExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
// 线程池任务队容量,如果不设置则默认 Integer.MAX_VALUE,
// 队列默认使用LinkedBlockingQueue 若queueCapacity的值 <= 0,则使用SynchronousQueue
taskExecutor.setQueueCapacity(1000);
// 线程池中核心线程是否允许超时,默认为false
taskExecutor.setAllowCoreThreadTimeOut(true);
// 线程池中的超时处理时间,单位秒,有一个对应方法为毫秒,默认为不超时
taskExecutor.setAwaitTerminationSeconds(60);
// 初始化线程池,不可以少,否者会抛出 线程池没有初始化
taskExecutor.initialize();
return taskExecutor;
}
/**
* 线程未处理异常的统一处理机制,即线程池异常处理器,简单示例
*
* @return
*/
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
// 异常处理器函数接口类
return new AsyncUncaughtExceptionHandler() {
@Override
public void handleUncaughtException(Throwable throwable, Method method, Object... objects) {
logger.error("============ " + throwable.getMessage() + " ===========", throwable);
logger.error("============ " + method.getName() + " ===========", objects);
}
};
}
}
spring.application.name=AMOS-API-HOUSEPVAPI
spring.application.name=AMOS-API-HOUSEPVAPI-WJ
server.servlet.context-path=/housepvapi
server.port=11006
......
......@@ -15,4 +15,10 @@ public interface TdHYGFInverterDayGenerateMapper extends BaseMapper<TdHYGFInvert
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHYGFInverterDayGenerate> selectList(@Param(Constants.WRAPPER) Wrapper<TdHYGFInverterDayGenerate> queryWrapper);
// @UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<Map<String,Object>> selectSnCodeList(String startTime, String endTime, List<String> sncodes);
@UserEmpower(field ={"regional_companies_code"},dealerField ={"amos_company_code","regional_companies_code"} ,fieldConditions ={"eq","in"} ,relationship="and")
List<TdHYGFInverterDayGenerate> selectListPage(List<String> snCodeList, List<String> maxCreatedTimeList);
}
......@@ -301,8 +301,6 @@
<select id="getCountJpStationdata" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.JpStationDto">
select
ROUND(sum(real_time_power),3) realTimePower,
ROUND(sum(capacity)/1000,3) capacity,
......
......@@ -23,4 +23,59 @@
</select>
<!-- <select id="selectListPage" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate">-->
<!-- SELECT-->
<!-- *-->
<!-- from-->
<!-- house_pv_data.td_hygf_inverter_day_generate-->
<!-- <where>-->
<!-- created_time >= #{startTime} and created_time &lt;= #{endTime}-->
<!-- <if test="sncodes != null and sncodes.size>0">-->
<!-- sn_code in-->
<!-- <foreach collection="sncodes" item="sncode" open="(" close=")" separator=",">-->
<!-- #{sncode}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- </where>-->
<!-- </select>-->
<select id="selectSnCodeList" resultType="map">
SELECT
sn_code, max(TO_UNIXTIMESTAMP(TO_ISO8601(created_time))) max_created_time
from
house_pv_data.td_hygf_inverter_day_generate
<where>
created_time >= #{startTime} and created_time &lt;= #{endTime}
<if test="sncodes != null and sncodes.size>0">
sn_code in
<foreach collection="sncodes" item="sncode" open="(" close=")" separator=",">
#{sncode}
</foreach>
</if>
</where>
GROUP BY sn_code
</select>
<select id="selectListPage" resultType="com.yeejoin.amos.boot.module.hygf.api.entity.TdHYGFInverterDayGenerate">
SELECT
*
from
house_pv_data.td_hygf_inverter_day_generate
<where>
<if test="snCodeList != null and snCodeList.size>0">
sn_code in
<foreach collection="snCodeList" item="sncode" open="(" close=")" separator=",">
#{sncode}
</foreach>
</if>
<if test="maxCreatedTimeList != null and maxCreatedTimeList.size>0">
and created_time in
<foreach collection="maxCreatedTimeList" item="maxCreatedTime" open="(" close=")" separator=",">
#{maxCreatedTime}
</foreach>
</if>
</where>
order by created_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -40,10 +40,25 @@ import java.util.stream.Collectors;
@RequestMapping(value = "/jp-station")
public class JpStationController extends BaseController {
private static Double CARBON = 0.997 * 0.001;
private static Double SULFUR = 0.03 * 0.001;
private static Double DUST = 0.272 * 0.001;
private static Double COAL = 0.4 * 0.001;
// //炭
// private static Double CARBON = 0.997 * 0.001;
// //硫
// private static Double SULFUR = 0.03 * 0.001;
// //粉尘
// private static Double DUST = 0.272 * 0.001;
// //煤
// private static Double COAL = 0.4 * 0.001;
//炭
private static Double CARBON = 832 * 0.001 * 0.001;
//硫
private static Double SULFUR = 0.16 * 0.001 * 0.001;
//粉尘
private static Double DUST = 0.032 * 0.001 * 0.001;
//煤
private static Double COAL = 304.9 * 0.001 * 0.001;
private static String ZX = "在线";
private static String LX = "离线";
private static String BJ = "报警";
......@@ -485,7 +500,7 @@ public class JpStationController extends BaseController {
if(jpStation==null){
jpStation = new JpStationDto();
}
if (jpStation != null && jpStation.getRealTimePower() != null && jpStation.getRatedPower() != null && jpStation.getRatedPower() > 0) {
if (jpStation != null && jpStation.getRealTimePower() != null && jpStation.getCapacity() != null && jpStation.getCapacity() > 0) {
map.put("value", String.format("%.4f", jpStation.getRealTimePower() / (jpStation.getCapacity() * FDXSS)));
} else {
map.put("value", 0);
......@@ -543,6 +558,8 @@ public class JpStationController extends BaseController {
map.put("dust", format2.format(accumulatedPower * FDXSS * DUST));
//煤
map.put("coal", format2.format(accumulatedPower * FDXSS * COAL));
itemList.add(map);
result.setCurrent(1);
result.setTotal(1);
......
......@@ -26,6 +26,9 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
......@@ -118,7 +121,8 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
String key1 = treeParam.get("key").toString();
if (treeParam.get("key").toString().startsWith("acc")||treeParam.get("key").toString().startsWith("acv")||treeParam.get("key").toString().startsWith("pv")){
key1 =treeParam.get("key").toString().replace("_","");
} value.add(obj.get(key1).toString());
}
value.add(obj.get(key1).toString());
}
treeParam.put("data",value);
}
......@@ -132,23 +136,51 @@ public class JpInverterServiceImpl extends BaseService<JpInverterDto, JpInverter
@UserLimits
public Page<TdHYGFInverterDayGenerate> jpInverterDayReport(int current, int size, String time, List<String> sncodes, List<String> stationIds) {
Page<TdHYGFInverterDayGenerate> tdHYGFInverterDayGeneratePage = new Page<>();
Date date = DateUtil.parse(time, "yyyy-MM-dd");
Date timeStart = DateUtils.dateAddHours(date, -8);
Date tiemEnd = DateUtils.dateAddHours(date, 16);
String startTime = DateUtil.format(timeStart, "yyyy-MM-dd HH:mm:ss");
String endTime = DateUtil.format(tiemEnd, "yyyy-MM-dd HH:mm:ss");
QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
.ge("created_time", startTime)
.le("created_time", endTime);
// .in("third_station_id", stationIds);
;
if (CollectionUtil.isNotEmpty(sncodes)) {
queryWrapper.in("sn_code", sncodes);
// Date date = DateUtil.parse(time, "yyyy-MM-dd");
// Date timeStart = DateUtils.dateAddHours(date, -8);
// Date tiemEnd = DateUtils.dateAddHours(date, 16);
// String startTime = DateUtil.format(timeStart, "yyyy-MM-dd HH:mm:ss");
// String endTime = DateUtil.format(tiemEnd, "yyyy-MM-dd HH:mm:ss");
CharSequence time1 = time + " 00:00:00";
CharSequence time2 = time + " 23:59:59";
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String startTime = DateUtil.format(LocalDateTime.parse(time1,df), "yyyy-MM-dd HH:mm:ss");
String endTime = DateUtil.format(LocalDateTime.parse(time2,df), "yyyy-MM-dd HH:mm:ss");
// QueryWrapper queryWrapper = new QueryWrapper<TdHYGFInverterDayGenerate>()
// .ge("created_time", startTime)
// .le("created_time", endTime);
//// .in("third_station_id", stationIds);
// ;
// if (CollectionUtil.isNotEmpty(sncodes)) {
// queryWrapper.in("sn_code", sncodes);
// }
// queryWrapper.orderByDesc("created_time");
//
// PageHelper.startPage(current, size);
// List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectList(queryWrapper);
List<Map<String, Object>> listData = tdHYGFInverterDayGenerateMapper.selectSnCodeList(startTime, endTime, sncodes);
List<String> snCodeList = new ArrayList<>();
List<String> maxCreatedTimeList = new ArrayList<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
listData.stream().forEach(item -> {
if(item.get("sn_code") != null) {
snCodeList.add(item.get("sn_code").toString());
}
queryWrapper.orderByDesc("created_time");
if(item.get("max_created_time") != null) {
maxCreatedTimeList.add(sdf.format(item.get("max_created_time")));
}
});
PageHelper.startPage(current, size);
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectList(queryWrapper);
List<TdHYGFInverterDayGenerate> tdHYGFInverterDayGenerates = tdHYGFInverterDayGenerateMapper.selectListPage(snCodeList, maxCreatedTimeList);
tdHYGFInverterDayGenerates.forEach(tdHYGFInverterDayGenerate -> {
Date date1 = new Date(tdHYGFInverterDayGenerate.getCreatedTime());
tdHYGFInverterDayGenerate.setCreatedTimeStr(DateUtil.format(date1, DatePattern.NORM_DATETIME_PATTERN));
......
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-biz/1.0.0/amos-boot-module-common-biz-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-api/1.0.0/amos-boot-module-common-api-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-data-elasticsearch/2.3.11.RELEASE/spring-boot-starter-data-elasticsearch-2.3.11.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/data/spring-data-elasticsearch/4.0.9.RELEASE/spring-data-elasticsearch-4.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-biz/1.0.0/amos-boot-module-common-biz-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-api/1.0.0/amos-boot-module-common-api-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-data-elasticsearch/2.3.11.RELEASE/spring-boot-starter-data-elasticsearch-2.3.11.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/data/spring-data-elasticsearch/4.0.9.RELEASE/spring-data-elasticsearch-4.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
......@@ -38,6 +38,8 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/**
* @description:
* @author: tw
......@@ -72,16 +74,17 @@ public class LargeScreenImpl {
* 全国
*/
@Scheduled(cron = "0/10 * * * * ?")
@PostConstruct
public Map<String, Double> getqg() {
Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d);
// mapdta.put("RSD", 0d);
// mapdta.put("YFD", 0d);
// mapdta.put("NFD", 0d);
// mapdta.put("YJHWC", 0d);
// mapdta.put("NJHWC", 0d);
//平均数
List<String> value = new ArrayList<>();
value.add(SS);
......@@ -113,37 +116,37 @@ public class LargeScreenImpl {
}
}
}
//日发电量
AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
//月发电量
AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
//年发电量
AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) {
if ("FDZ".equals(stationCacheInfoDto.getStationType())) {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
} else {
Map<String, List<String>> queryCondtion = new HashMap<>();
queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
}
}
mapdta.put("RSD", keepFourdecimalPlaces(dailyPower.get()));
mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get()));
mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get()));
// //日发电量
// AtomicReference<Double> dailyPower = new AtomicReference<>(0.0);
// //月发电量
// AtomicReference<Double> monthlyPower = new AtomicReference<>(0.0);
// //年发电量
// AtomicReference<Double> annualPower = new AtomicReference<>(0.0);
// for (StationCacheInfoDto stationCacheInfoDto : stationCacheInfoDtos) {
//
// if ("FDZ".equals(stationCacheInfoDto.getStationType())) {
// Map<String, List<String>> queryCondtion = new HashMap<>();
// queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, Arrays.asList("日发电量", "月发电量", "年发电量"));
// queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getFanGatewayId()));
// List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
// dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "日发电量")));
// monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "月发电量")));
// annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, "年发电量")));
// } else {
// Map<String, List<String>> queryCondtion = new HashMap<>();
// queryCondtion.put(CommonConstans.QueryStringEquipmentIndexName, CommonConstans.taiHeGenIndicator);
// queryCondtion.put(CommonConstans.QueryStringGateWayId, Arrays.asList(stationCacheInfoDto.getBoosterGatewayId()));
// List<ESEquipments> result = commonServiceImpl.getListDataByCondtions(queryCondtion, null, ESEquipments.class);
// dailyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorDay)));
// monthlyPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorMonth)));
// annualPower.updateAndGet(v -> v + keepFourdecimalPlaces(commonServiceImpl.getSumByEquipmentIndxName(result, CommonConstans.taiHeGenIndicatorYear)));
// }
//
// }
//
// mapdta.put("RSD", keepFourdecimalPlaces(dailyPower.get()));
// mapdta.put("YFD", keepFourdecimalPlaces(monthlyPower.get()));
// mapdta.put("NFD", keepFourdecimalPlaces(annualPower.get()));
//总和
// value.clear();
......@@ -172,28 +175,28 @@ public class LargeScreenImpl {
// }
// }
// }
//计算月完成百分比
//当前月份 获取
LocalDate currentDate = LocalDate.now();
int month = currentDate.getMonthValue();
QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
wrapper.select("ifnull(sum(value), 0) as sum_value");
wrapper.eq("monthly", month);
List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper);
Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
//计算年完成百分比
Double ybfb = sumValue > 0 ? mapdta.get("YFD") / sumValue * 100 : 0;
ybfb = new BigDecimal(ybfb).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
mapdta.put("YJHWC", ybfb);
QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>();
wrapper1.select("ifnull(sum(value), 0) as sum_value");
List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1);
Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0;
Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0;
ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
mapdta.put("NJHWC", ybfbn);
// //计算月完成百分比
// //当前月份 获取
// LocalDate currentDate = LocalDate.now();
// int month = currentDate.getMonthValue();
//
// QueryWrapper<StationPlan> wrapper = new QueryWrapper<>();
// wrapper.select("ifnull(sum(value), 0) as sum_value");
// wrapper.eq("monthly", month);
// List<Map<String, Object>> list = StationPlanMapper.selectMaps(wrapper);
// Double sumValue = list != null && !list.isEmpty() ? (Double) list.get(0).get("sum_value") : 0;
// //计算年完成百分比
// Double ybfb = sumValue > 0 ? mapdta.get("YFD") / sumValue * 100 : 0;
// ybfb = new BigDecimal(ybfb).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
//
// mapdta.put("YJHWC", ybfb);
// QueryWrapper<StationPlan> wrapper1 = new QueryWrapper<>();
// wrapper1.select("ifnull(sum(value), 0) as sum_value");
// List<Map<String, Object>> list1 = StationPlanMapper.selectMaps(wrapper1);
// Double sumValuen = list1 != null && !list1.isEmpty() ? (Double) list1.get(0).get("sum_value") : 0;
// Double ybfbn = sumValuen > 0 ? mapdta.get("NFD") / sumValue * 100 : 0;
// ybfbn = new BigDecimal(ybfbn).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue();
// mapdta.put("NJHWC", ybfbn);
try {
emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(),0,true);
} catch (MqttException e) {
......
......@@ -570,46 +570,45 @@ public class MonitorServiceImpl implements MonitorService {
*
* @return 返回一个包含各种指标数据的map,其中键为指标名称,值为指标数值。
*/
public Map<String, Double> getqg() {
// 初始化存储数据的map,设置默认值为0
Map<String, Double> mapdta = new HashMap<>();
mapdta.put("SS", 0d);
mapdta.put("ZFS", 0d);
mapdta.put("ZFSLJ", 0d);
mapdta.put("RSD", 0d);
mapdta.put("YFD", 0d);
mapdta.put("NFD", 0d);
mapdta.put("YJHWC", 0d);
mapdta.put("NJHWC", 0d);
// 获取核心数值数据
List<CoreValuesDto> coreValuesDtos = new ArrayList<>();
coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
// 构建请求URL并发起HTTP GET请求,获取相关数据
String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url;
List<BuDunGenDto> buDunGenDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunGenDto.class);
// 如果有获取到数据,则更新map中的相应数据
if (buDunGenDtos.size() > 0) {
BuDunGenDto buDunGenDto = buDunGenDtos.get(0);
mapdta.put("RSD", keepFourdecimalPlaces(buDunGenDto.getDay()));
mapdta.put("YFD", keepFourdecimalPlaces(buDunGenDto.getMonth()));
mapdta.put("NFD", keepFourdecimalPlaces(buDunGenDto.getYear()));
mapdta.put("YJHWC", keepTwodecimalPlaces(buDunGenDto.getMonth_complete()));
mapdta.put("NJHWC", keepTwodecimalPlaces(buDunGenDto.getYear_complete()));
}
// 更新map中剩余的数据项
mapdta.put("SS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.WIND_SPEED_THIRTY_SECONDS)));
mapdta.put("ZFS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION)));
mapdta.put("ZFSLJ", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION_SUM)));
// 将数据发布到MQTT主题
try {
emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(), 0, true);
} catch (MqttException e) {
e.printStackTrace();
}
return mapdta;
}
// public Map<String, Double> getqg() {
//
// // 初始化存储数据的map,设置默认值为0
// Map<String, Double> mapdta = new HashMap<>();
// mapdta.put("SS", 0d);
// mapdta.put("ZFS", 0d);
// mapdta.put("ZFSLJ", 0d);
// mapdta.put("RSD", 0d);
// mapdta.put("YFD", 0d);
// mapdta.put("NFD", 0d);
// mapdta.put("YJHWC", 0d);
// mapdta.put("NJHWC", 0d);
// // 获取核心数值数据
// List<CoreValuesDto> coreValuesDtos = new ArrayList<>();
// coreValuesDtos = coreCommonService.getValuesByStationNamesAndPointsNames(null, null);
// // 构建请求URL并发起HTTP GET请求,获取相关数据
// String requestUrl = Constants.BASE_URL + "?" + Constants.get_area_item_url;
// List<BuDunGenDto> buDunGenDtos = httpRequestUtil.getResPonse(requestUrl, Constants.REQUEST_GET, "", Constants.resovleRule_data, BuDunGenDto.class);
// // 如果有获取到数据,则更新map中的相应数据
// if (buDunGenDtos.size() > 0) {
// BuDunGenDto buDunGenDto = buDunGenDtos.get(0);
// mapdta.put("RSD", keepFourdecimalPlaces(buDunGenDto.getDay()));
// mapdta.put("YFD", keepFourdecimalPlaces(buDunGenDto.getMonth()));
// mapdta.put("NFD", keepFourdecimalPlaces(buDunGenDto.getYear()));
// mapdta.put("YJHWC", keepTwodecimalPlaces(buDunGenDto.getMonth_complete()));
// mapdta.put("NJHWC", keepTwodecimalPlaces(buDunGenDto.getYear_complete()));
// }
// // 更新map中剩余的数据项
// mapdta.put("SS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.WIND_SPEED_THIRTY_SECONDS)));
// mapdta.put("ZFS", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION)));
// mapdta.put("ZFSLJ", keepTwodecimalPlaces(coreCommonService.getAverageOfByPointName(coreValuesDtos, CommonConstans.TOTAL_RADIATION_SUM)));
// // 将数据发布到MQTT主题
// try {
// emqKeeper.getMqttClient().publish("qg/yxzb", JSON.toJSONString(mapdta).getBytes(), 0, true);
// } catch (MqttException e) {
// e.printStackTrace();
// }
// return mapdta;
// }
@Scheduled(cron = "0/10 * * * * ?")
private void sendQYYXZBMqtt() {
......
......@@ -23,7 +23,7 @@ spring.db4.datasource.password=taosdata
spring.db4.datasource.driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
## eureka properties:
eureka.instance.hostname=172.16.10.220
eureka.instance.hostname=10.20.1.160
eureka.client.serviceUrl.defaultZone=http://admin:a1234560@${eureka.instance.hostname}:10001/eureka/
## redis properties:
spring.redis.database=1
......@@ -63,10 +63,10 @@ lettuce.timeout=10000
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.220:1883
emqx.broker=tcp://10.20.1.210:2883
emqx.user-name=admin
emqx.password=public
mqtt.scene.host=mqtt://172.16.10.220:8083/mqtt
mqtt.scene.host=mqtt://10.20.1.210:8083/mqtt
mqtt.client.product.id=mqtt
mqtt.topic=topic_mqtt
spring.mqtt.completionTimeout=3000
......
spring.application.name=AMOS-JXIOP-BIGSCREEN
spring.application.name=AMOS-JXIOP-BIGSCREEN-WJ
server.servlet.context-path=/jxiop-bigscreen
server.port=33300
server.uri-encoding=UTF-8
......
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-biz/1.0.0/amos-boot-module-common-biz-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-api/1.0.0/amos-boot-module-common-api-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-data-elasticsearch/2.3.11.RELEASE/spring-boot-starter-data-elasticsearch-2.3.11.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/data/spring-data-elasticsearch/4.0.9.RELEASE/spring-data-elasticsearch-4.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
This diff is collapsed.
<factorypath>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-biz/1.0.0/amos-boot-module-common-biz-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-api/1.0.0/amos-boot-module-common-api-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-data-elasticsearch/2.3.11.RELEASE/spring-boot-starter-data-elasticsearch-2.3.11.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/data/spring-data-elasticsearch/4.0.9.RELEASE/spring-data-elasticsearch-4.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
......@@ -13,6 +13,7 @@
<factorypathentry kind="VARJAR" id="M2_REPO/com/github/luben/zstd-jni/1.4.4-7/zstd-jni-1.4.4-7.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/lz4/lz4-java/1.7.1/lz4-java-1.7.1.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/xerial/snappy/snappy-java/1.1.7.3/snappy-java-1.1.7.3.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-biz/1.0.0/amos-boot-module-common-biz-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/com/amosframework/boot/amos-boot-module-common-api/1.0.0/amos-boot-module-common-api-1.0.0.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/boot/spring-boot-starter-data-elasticsearch/2.3.11.RELEASE/spring-boot-starter-data-elasticsearch-2.3.11.RELEASE.jar" enabled="true" runInBatchMode="false"/>
<factorypathentry kind="VARJAR" id="M2_REPO/org/springframework/data/spring-data-elasticsearch/4.0.9.RELEASE/spring-data-elasticsearch-4.0.9.RELEASE.jar" enabled="true" runInBatchMode="false"/>
......
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