Commit 25c1b88a authored by wujiang's avatar wujiang

修改生成指数问题

parent 779ac0bc
...@@ -24,11 +24,13 @@ import org.springframework.context.ConfigurableApplicationContext; ...@@ -24,11 +24,13 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.restful.exception.GlobalExceptionHandler;
import java.net.InetAddress; import java.net.InetAddress;
...@@ -52,7 +54,8 @@ import java.net.InetAddress; ...@@ -52,7 +54,8 @@ import java.net.InetAddress;
"com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper", "com.yeejoin.amos.boot.module.**.api.mapper", "com.yeejoin.amos.boot.biz.common.dao.mapper",
"com.yeejoin.amos.boot.module.common.biz.*", "com.yeejoin.amos.boot.module.jxiop.api.mapper", "com.yeejoin.amos.boot.module.common.biz.*", "com.yeejoin.amos.boot.module.jxiop.api.mapper",
"com.yeejoin.amos.boot.module.jxiop.biz.tdmapper", "com.yeejoin.amos.boot.module.jxiop.biz.mapper5" }) "com.yeejoin.amos.boot.module.jxiop.biz.tdmapper", "com.yeejoin.amos.boot.module.jxiop.biz.mapper5" })
@ComponentScan(basePackages = { "org.typroject", "com.yeejoin.amos" }) @ComponentScan(basePackages = { "org.typroject", "com.yeejoin.amos" },excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {
GlobalExceptionHandler.class }))
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class })
//@SpringBootApplication //@SpringBootApplication
public class AmosJxiopAnalyseApplication { public class AmosJxiopAnalyseApplication {
...@@ -86,8 +89,8 @@ public class AmosJxiopAnalyseApplication { ...@@ -86,8 +89,8 @@ public class AmosJxiopAnalyseApplication {
return; return;
} }
// 订阅固化周期性数据成功的消息 // 订阅固化周期性数据成功的消息
emqKeeper.subscript("sync_esdata_to_tdengine_notice", 1, syncESDataToTdengineMqttListener); emqKeeper.subscript("sync_esdata_to_tdengine_notice1", 1, syncESDataToTdengineMqttListener);
// 订阅业务固化同步数据成功消息 // 订阅业务固化同步数据成功消息
emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener); //emqKeeper.subscript("sync_iotdata_to_tdengine_notice", 1, syncDasSuccessMqttListener);
} }
} }
...@@ -1863,13 +1863,13 @@ public class TDBigScreenAnalyseController extends BaseController implements Appl ...@@ -1863,13 +1863,13 @@ public class TDBigScreenAnalyseController extends BaseController implements Appl
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
initStationFirstSelect(); //initStationFirstSelect();
} }
/** /**
* 初始化场站第一个选中 * 初始化场站第一个选中
*/ */
@Scheduled(cron = "0 */3 * * * ?") @Scheduled(cron = "0 */10 * * * ?")
public void initStationFirstSelect() { public void initStationFirstSelect() {
List<StationBasicDto> stationBasicDtos = stationBasicMapper.getStationBasicList(); List<StationBasicDto> stationBasicDtos = stationBasicMapper.getStationBasicList();
if(CollectionUtil.isNotEmpty(stationBasicDtos)){ if(CollectionUtil.isNotEmpty(stationBasicDtos)){
......
...@@ -85,6 +85,99 @@ public class TdInfoQueryController extends BaseController { ...@@ -85,6 +85,99 @@ public class TdInfoQueryController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanHealthIndexInfoOld")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
@GatewayIdAutowired
public ResponseModel<Page<FanHealthIndex>> getFanHealthIndexInfoOld(@RequestBody FanHealthIndexDto dto) throws ParseException {
ReginParams reginParams = getSelectedOrgInfo();
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
String orgCode = "86"+"%";
if (!ObjectUtils.isEmpty(stdUserEmpower)) {
orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%";
}
dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, 0), DATE_TIME_PATTERN));
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Date date = DateUtils.dateParse(startDate + ":00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -9), DATE_TIME_PATTERN));
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
StringBuilder newStartDate = new StringBuilder(startDate);
int number = 0;
if((newStartDate.charAt(15) - '0') > 0) {
number = 9;
}
newStartDate.replace(15, 16, number+"");
Date startDateDate = DateUtils.dateParse(newStartDate + ":00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(startDateDate, -8), DATE_TIME_PATTERN));
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
}
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, 0), DATE_TIME_PATTERN));
}else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Date endDateDate = DateUtils.dateParse(endDate + ":59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -9), DATE_TIME_PATTERN));
} else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
StringBuilder newEndDate = new StringBuilder(endDate);
newEndDate.replace(15, 16, "9");
Date endDateDate = DateUtils.dateParse(newEndDate + ":59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
} else {
Date endDateDate = DateUtils.dateParse(endDate, "yyyy-MM-dd HH:mm:ss");
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
}
}
Page<FanHealthIndex> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
if (CharSequenceUtil.isNotEmpty(dto.getSortsString())) {
ObjectMapper objectMapper = new ObjectMapper();
try {
List<Map<String, String>> list = objectMapper.readValue(dto.getSortsString(), new TypeReference<List<Map<String, String>>>(){});
dto.setSorts(list);
} catch (Exception e) {
e.printStackTrace();
}
}
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = convert(map.get("columnKey")) + " " + replace;
orderByList.add(columnOrder);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
if (CharSequenceUtil.isNotEmpty(dto.getSortOne())) {
String[] split = dto.getSortOne().split(",");
String replace = split[1].replace("end", "");
String orderColumn = convert(split[0]) + " " + replace;
dto.setSortOne(orderColumn);
}
List<FanHealthIndex> fanHealthIndexIPage = fanHealthIndexMapper.getInfoByPage(dto);
fanHealthIndexIPage.forEach(item -> item.setHealthIndex(Double.valueOf(df.format(item.getHealthIndex()))));
Integer infoByPageTotal = fanHealthIndexMapper.getInfoByPageTotal(dto);
resultPage.setRecords(fanHealthIndexIPage);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanHealthIndexInfo") @PostMapping(value = "/getFanHealthIndexInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电") @ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
@GatewayIdAutowired @GatewayIdAutowired
...@@ -123,7 +216,7 @@ public class TdInfoQueryController extends BaseController { ...@@ -123,7 +216,7 @@ public class TdInfoQueryController extends BaseController {
String dateNowShortStr = DateUtils.getDateNowShortStr(); String dateNowShortStr = DateUtils.getDateNowShortStr();
String endDate = dto.getEndDate(); String endDate = dto.getEndDate();
if (dateNowShortStr.equals(endDate)){ if (dateNowShortStr.equals(endDate)){
Date date = DateUtils.dateAddDays(null, -1); Date date = DateUtils.dateAddDays(null, 0);
SimpleDateFormat formatter = new SimpleDateFormat(DateUtils.DATE_PATTERN); SimpleDateFormat formatter = new SimpleDateFormat(DateUtils.DATE_PATTERN);
endDate= formatter.format(date); endDate= formatter.format(date);
} }
...@@ -312,6 +405,104 @@ public class TdInfoQueryController extends BaseController { ...@@ -312,6 +405,104 @@ public class TdInfoQueryController extends BaseController {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getPvHealthIndexInfoOld")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 光伏", notes = "分页查询健康指数信息 - 光伏")
@GatewayIdAutowired
public ResponseModel<Page<PvHealthIndex>> getPvHealthIndexInfoOld(@RequestBody PvHealthIndexDto dto) throws ParseException {
ReginParams reginParams = getSelectedOrgInfo();
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
String orgCode = "86"+"%";
if (!ObjectUtils.isEmpty(stdUserEmpower)) {
orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%";
}
dto.setOrgCode(orgCode);
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
Date date = DateUtils.dateParse(startDate + " 00:00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, 0), DATE_TIME_PATTERN));
}else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
Date date = DateUtils.dateParse(startDate + ":00:00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -9), DATE_TIME_PATTERN));
} else if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
StringBuilder newStartDate = new StringBuilder(startDate);
int number = 0;
if((newStartDate.charAt(15) - '0') > 0) {
number = 9;
}
newStartDate.replace(15, 16, number+"");
Date startDateDate = DateUtils.dateParse(newStartDate + ":00", DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(startDateDate, -8), DATE_TIME_PATTERN));
} else {
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
dto.setStartDate(DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN));
}
}
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
Date endDateDate = DateUtils.dateParse(endDate + " 23:59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, 0), DATE_TIME_PATTERN));
}else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
Date endDateDate = DateUtils.dateParse(endDate + ":59:59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -9), DATE_TIME_PATTERN));
} else
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
StringBuilder newEndDate = new StringBuilder(endDate);
newEndDate.replace(15, 16, "9");
Date endDateDate = DateUtils.dateParse(newEndDate + ":59", DATE_TIME_PATTERN);
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
} else {
Date endDateDate = DateUtils.dateParse(endDate, "yyyy-MM-dd HH:mm:ss");
dto.setEndDate(DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN));
}
}
if (CharSequenceUtil.isNotEmpty(dto.getSortsString())) {
ObjectMapper objectMapper = new ObjectMapper();
try {
List<Map<String, String>> list = objectMapper.readValue(dto.getSortsString(), new TypeReference<List<Map<String, String>>>(){});
dto.setSorts(list);
} catch (Exception e) {
e.printStackTrace();
}
}
Page<PvHealthIndex> resultPage = new Page<>(dto.getCurrent(), dto.getSize());
dto.setCurrent((dto.getCurrent() - 1) * dto.getSize());
List<Map<String, String>> orderWeight = dto.getSorts().stream().sorted(Comparator.comparing(t -> Integer.parseInt(t.get("orderWeight")))).collect(Collectors.toList());
List<String> orderByList = new ArrayList<>();
for (Map<String, String> map : orderWeight) {
String replace = map.get("order").replace("end", "");
String columnOrder = convert(map.get("columnKey")) + " " + replace;
orderByList.add(columnOrder);
}
if (CharSequenceUtil.isNotEmpty(dto.getSortOne())) {
String[] split = dto.getSortOne().split(",");
String replace = split[1].replace("end", "");
String orderColumn = convert(split[0]) + " " + replace;
dto.setSortOne(orderColumn);
}
String join = String.join(",", orderByList);
dto.setOrderColumns(join);
List<PvHealthIndex> pvHealthIndexIPage = pvHealthIndexMapper.getInfoByPage(dto);
pvHealthIndexIPage.forEach(item -> item.setHealthIndex(Double.valueOf(df.format(item.getHealthIndex()))));
Integer infoByPageTotal = pvHealthIndexMapper.getInfoByPageTotal(dto);
resultPage.setRecords(pvHealthIndexIPage);
resultPage.setTotal(infoByPageTotal);
return ResponseHelper.buildResponse(resultPage);
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanWarningRecordInfo") @PostMapping(value = "/getFanWarningRecordInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电") @ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
@GatewayIdAutowired @GatewayIdAutowired
......
...@@ -9,6 +9,9 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceIm ...@@ -9,6 +9,9 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.TdengineTimeServiceIm
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.MqttMessage; import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqxListener; import org.typroject.tyboot.component.emq.EmqxListener;
...@@ -27,6 +30,7 @@ import java.util.concurrent.TimeUnit; ...@@ -27,6 +30,7 @@ import java.util.concurrent.TimeUnit;
*/ */
@Component @Component
@Slf4j @Slf4j
@EnableScheduling
public class SyncESDataToTdengineMqttListener extends EmqxListener { public class SyncESDataToTdengineMqttListener extends EmqxListener {
@Autowired @Autowired
...@@ -43,20 +47,13 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -43,20 +47,13 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
@PostConstruct @PostConstruct
public void test() { public void test() {
// 每次启动清空redis // 每次启动清空redis
//redisUtils.set(JXIOP_ANALYSE_TIME, "2024-07-30 13:40:00"); // redisUtils.set(JXIOP_ANALYSE_TIME, "2024-07-30 13:40:00");
redisUtils.del(JXIOP_ANALYSE_TIME); redisUtils.del(JXIOP_ANALYSE_TIME);
} }
@Override // @Async("async")
public void processMessage(String topic, MqttMessage mqttMessage) throws ParseException { @Scheduled(cron = "0 */10 * * * ?")
log.info(topic + "收到数据同步成功,开始计算健康指数!"); public void run() throws ParseException {
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString();
if ("success".equals(flag)) {
Date time = new Date(); Date time = new Date();
time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
...@@ -76,15 +73,23 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -76,15 +73,23 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
System.out.println(format); System.out.println(format);
final Date timeF = time; final Date timeF = time;
CompletableFuture<String> fan=CompletableFuture.supplyAsync(()->{ CompletableFuture<String> fan = CompletableFuture.supplyAsync(() -> {
try {
commonServiceImpl.healthWarningMinuteByFan(timeF); commonServiceImpl.healthWarningMinuteByFan(timeF);
} catch (Exception e) {
e.printStackTrace();
}
String fanResult = "风电任务完成.."; String fanResult = "风电任务完成..";
System.out.println(fanResult); System.out.println(fanResult);
return fanResult; return fanResult;
}); });
CompletableFuture<String> pv=CompletableFuture.supplyAsync(()->{ CompletableFuture<String> pv = CompletableFuture.supplyAsync(() -> {
try {
commonServiceImpl.healthWarningMinuteByPv(timeF); commonServiceImpl.healthWarningMinuteByPv(timeF);
} catch (Exception e) {
e.printStackTrace();
}
String pvResult = "光伏任务完成.."; String pvResult = "光伏任务完成..";
System.out.println(pvResult); System.out.println(pvResult);
return pvResult; return pvResult;
...@@ -94,16 +99,28 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -94,16 +99,28 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
String pvResult = pv.get(); String pvResult = pv.get();
// 区域 全域最后统一生成 // 区域 全域最后统一生成
tdengineTimeService.insertMomentDataAll(format); tdengineTimeService.insertMomentDataAll(format);
if (isWholeHour(format)){ if (isWholeHour(format)) {
tdengineTimeService.insertHourData(); tdengineTimeService.insertHourData();
} }
if (isWholeDay(format)){ if (isWholeDay(format)) {
tdengineTimeService.insertDayData(); tdengineTimeService.insertDayData();
} }
} catch (InterruptedException | ExecutionException e) { } catch (InterruptedException | ExecutionException e) {
System.out.println("任务执行异常"); System.out.println("任务执行异常");
e.printStackTrace(); e.printStackTrace();
} }
}
@Override
public void processMessage(String topic, MqttMessage mqttMessage) throws ParseException {
log.info(topic + "收到数据同步成功,开始计算健康指数!");
byte[] payload = mqttMessage.getPayload();
String str = new String(payload);
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String flag = jsonObject.get("sync_flag").toString();
if ("success".equals(flag)) {
run();
// //
// ExecutorService excutorService = Executors.newFixedThreadPool(10); // ExecutorService excutorService = Executors.newFixedThreadPool(10);
// int taskCount = 2; // int taskCount = 2;
...@@ -159,6 +176,7 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener { ...@@ -159,6 +176,7 @@ public class SyncESDataToTdengineMqttListener extends EmqxListener {
// }).start(); // }).start();
// } // }
} }
private boolean isWholeHour(String dateTimeStr) { private boolean isWholeHour(String dateTimeStr) {
try { try {
DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
......
...@@ -289,12 +289,13 @@ public class CommonServiceImpl { ...@@ -289,12 +289,13 @@ public class CommonServiceImpl {
// >= '%s' and time <= '%s' ", tableName, // >= '%s' and time <= '%s' ", tableName,
// idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, // idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime,
// endTime); // endTime);
// List<IndicatorData> returnList = idxBizPvPointProcessVariableClassificationMapper.selectDataByAddressAndtimeTs( // List<IndicatorData> returnList =
// idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName); // idxBizPvPointProcessVariableClassificationMapper.selectDataByAddressAndtimeTs(
// idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime,
// endTime, tableName);
List<IndicatorData> returnList = indicatorDataMapper.selectDataByAddressAndtimeTs( List<IndicatorData> returnList = indicatorDataMapper.selectDataByAddressAndtimeTs(
idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName); idxBizFanPointProcessVariableClassification.getIndexAddress(), startTime, endTime, tableName);
// List<Map<String, Object>> returnList = influxdbUtil.query(sql); // List<Map<String, Object>> returnList = influxdbUtil.query(sql);
returnList.forEach((k) -> { returnList.forEach((k) -> {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
...@@ -309,7 +310,8 @@ public class CommonServiceImpl { ...@@ -309,7 +310,8 @@ public class CommonServiceImpl {
HashMap<String, Object> realParams = new HashMap<>(); HashMap<String, Object> realParams = new HashMap<>();
realParams.put(gkqjhfkey, params); realParams.put(gkqjhfkey, params);
logger.info("------------------------------------------调用地址:" + baseUrl + gkqjhfurlfan); logger.info("------------------------------------------调用地址:" + baseUrl + gkqjhfurlfan);
logger.info("------------------------------------------调用参数:" + JSON.toJSONString(JSON.toJSONString(realParams))); logger.info("------------------------------------------调用参数:"
+ JSON.toJSONString(JSON.toJSONString(realParams)));
String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams)) String response = HttpUtil.createPost(baseUrl + gkqjhfurlfan).body(JSON.toJSONString(realParams))
.execute().body(); .execute().body();
if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) { if (response.contains("\"status\":200") && response.contains("rows") && response.contains("rows")) {
...@@ -601,12 +603,14 @@ public class CommonServiceImpl { ...@@ -601,12 +603,14 @@ public class CommonServiceImpl {
idxBizFanPointVarCorrelation idxBizFanPointVarCorrelation
.setCorrelationCoefficient(values.getDoubleValue("correlation_coefficient")); .setCorrelationCoefficient(values.getDoubleValue("correlation_coefficient"));
idxBizFanPointVarCorrelationMapper.updateById(idxBizFanPointVarCorrelation); idxBizFanPointVarCorrelationMapper.updateById(idxBizFanPointVarCorrelation);
logger.info("------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------"); logger.info(
"------------------------------------------风机相关性::相关性更新业务表成功----------------------------------------");
} }
try { try {
logger.info("response-------------" + response); logger.info("response-------------" + response);
TimeUnit.SECONDS.sleep(sleepTime); TimeUnit.SECONDS.sleep(sleepTime);
logger.info("----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------"); logger.info(
"----------------------------风机相关性--------------分析变量与工况变量相关性分析算法结束----------------------------------------");
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
...@@ -1893,14 +1897,16 @@ public class CommonServiceImpl { ...@@ -1893,14 +1897,16 @@ public class CommonServiceImpl {
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream() Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(),
IndicatorData::getValueF, IndicatorData::getValueF, (value1, value2) -> value1)); // 将测点id与值处理成map
(value1, value2) -> value1)); // 将测点id与值处理成map
HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>(); HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap)); log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap));
log.info("data" + JSONObject.toJSONString(data)); log.info("data" + JSONObject.toJSONString(data));
for (IdxBizFanPointProcessVariableClassificationDto datum : data) { for (IdxBizFanPointProcessVariableClassificationDto datum : data) {
Double currentValue = Double Float f = indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId());
.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId())); if (f == null) {
f = 0.0f;
}
Double currentValue = Double.valueOf(f);
if (!ObjectUtils.isEmpty(currentValue)) { if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue); datum.setCurrentValue(currentValue);
idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue); idxBizFanPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
...@@ -1955,6 +1961,9 @@ public class CommonServiceImpl { ...@@ -1955,6 +1961,9 @@ public class CommonServiceImpl {
} }
}); });
for (IdxBizFanPointVarCentralValue idxBizUhef : idxBizUhefs) { for (IdxBizFanPointVarCentralValue idxBizUhef : idxBizUhefs) {
if (idxBizUhef == null) {
continue;
}
double value1 = 0.00; double value1 = 0.00;
double value2 = 0.00; double value2 = 0.00;
double value3 = 0.00; double value3 = 0.00;
...@@ -1973,10 +1982,15 @@ public class CommonServiceImpl { ...@@ -1973,10 +1982,15 @@ public class CommonServiceImpl {
// value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue(); // value4 = datum.getCurrentValue() == null ? 0.0 : datum.getCurrentValue();
// } // }
// } // }
try {
value1 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id()); value1 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint1Id());
value2 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id()); value2 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint2Id());
value3 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id()); value3 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getProcessPoint3Id());
value4 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId()); value4 = idxBizFanPointProcessVariableClassificationDtoIdValueMap.get(idxBizUhef.getAnalysisPointId());
} catch (Exception e) {
e.printStackTrace();
}
if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max() if (idxBizUhef.getProcess1Min() <= value1 && value1 <= idxBizUhef.getProcess1Max()
&& idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max() && idxBizUhef.getProcess2Min() <= value2 && value2 <= idxBizUhef.getPorcess2Max()
&& idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) { && idxBizUhef.getProcess3Min() <= value3 && value3 <= idxBizUhef.getProcess3Max()) {
...@@ -2036,8 +2050,10 @@ public class CommonServiceImpl { ...@@ -2036,8 +2050,10 @@ public class CommonServiceImpl {
// List<Double> scoreValue = JSONObject.parseArray(scoreValueArray.toJSONString(), Double.class); // List<Double> scoreValue = JSONObject.parseArray(scoreValueArray.toJSONString(), Double.class);
// List<Double> indexValue = JSONObject.parseArray(indexValueArray.toJSONString(), Double.class); // List<Double> indexValue = JSONObject.parseArray(indexValueArray.toJSONString(), Double.class);
// Table resultTable = Table.create("healthData"); // Table resultTable = Table.create("healthData");
// healthData.addColumns(StringColumn.create("analysisVariableIdResult", jsonArrayToStringList), // healthData.addColumns(StringColumn.create("analysisVariableIdResult",
// DoubleColumn.create("indexValue", indexValue), DoubleColumn.create("scoreValue", scoreValue)); // jsonArrayToStringList),
// DoubleColumn.create("indexValue", indexValue),
// DoubleColumn.create("scoreValue", scoreValue));
// System.out.println(healthData.print()); // System.out.println(healthData.print());
try { try {
// healthData.write().csv(new Date().getTime() + "fj.csv"); // healthData.write().csv(new Date().getTime() + "fj.csv");
...@@ -2078,12 +2094,14 @@ public class CommonServiceImpl { ...@@ -2078,12 +2094,14 @@ public class CommonServiceImpl {
} }
} }
if (idxBizFanHealthIndex.getHealthIndex() == 0 && idxBizFanHealthIndex.getHealthLevel() == null) {
idxBizFanHealthIndex.setHealthLevel("危险");
}
idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName()); idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizFanHealthIndex.setAnalysisObjType("测点"); idxBizFanHealthIndex.setAnalysisObjType("测点");
if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) { if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) {
System.out.println(JSON.toJSONString(requestMap)); System.out.println(JSON.toJSONString(requestMap));
idxBizFanHealthIndex.setANOMALY(0.0); idxBizFanHealthIndex.setANOMALY(0.0);
} else { } else {
idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i)); idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
...@@ -2094,10 +2112,9 @@ public class CommonServiceImpl { ...@@ -2094,10 +2112,9 @@ public class CommonServiceImpl {
BeanUtil.copyProperties(idxBizFanHealthIndex, fanHealthIndex); BeanUtil.copyProperties(idxBizFanHealthIndex, fanHealthIndex);
fanHealthIndex.setWeight(idxBizFanHealthIndex.getWeigth()); fanHealthIndex.setWeight(idxBizFanHealthIndex.getWeigth());
fanHealthIndex.setAnomaly(idxBizFanHealthIndex.getANOMALY()); fanHealthIndex.setAnomaly(idxBizFanHealthIndex.getANOMALY());
fanHealthIndex.setRecDate(DateUtil.now());
fanHealthIndex.setArea(idxBizFanHealthIndex.getArae()); fanHealthIndex.setArea(idxBizFanHealthIndex.getArae());
fanHealthIndex.setAnalysisTime(format); fanHealthIndex.setAnalysisTime(format);
fanHealthIndex.setHealthLevel(fanHealthIndex.getHealthLevel()); fanHealthIndex.setHealthLevel(idxBizFanHealthIndex.getHealthLevel());
fanHealthIndex.setKks(idxBizFanHealthIndex.getKks()); fanHealthIndex.setKks(idxBizFanHealthIndex.getKks());
fanHealthIndex.setRecDate(format); fanHealthIndex.setRecDate(format);
fanHealthIndex.setOrgCode(obj.getOrgCode()); fanHealthIndex.setOrgCode(obj.getOrgCode());
...@@ -2190,8 +2207,7 @@ public class CommonServiceImpl { ...@@ -2190,8 +2207,7 @@ public class CommonServiceImpl {
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream() Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(),
IndicatorData::getValueF, IndicatorData::getValueF, (value1, value2) -> value1));
(value1, value2) -> value1));
// 将测点id与值处理成map // 将测点id与值处理成map
HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>(); HashMap<String, Double> idxBizFanPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap)); log.info("indicatorDataListAllMap" + JSONObject.toJSONString(indicatorDataListAllMap));
...@@ -2373,18 +2389,17 @@ public class CommonServiceImpl { ...@@ -2373,18 +2389,17 @@ public class CommonServiceImpl {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) { && indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizFanHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
} }
} }
if (idxBizFanHealthIndex.getHealthIndex() == 0 && idxBizFanHealthIndex.getHealthLevel() == null) {
idxBizFanHealthIndex.setHealthLevel("危险");
}
idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName()); idxBizFanHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizFanHealthIndex.setAnalysisObjType("测点"); idxBizFanHealthIndex.setAnalysisObjType("测点");
if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) { if (ObjectUtils.isEmpty(scoreValueArray.getDoubleValue(i))) {
System.out.println(JSON.toJSONString(requestMap));
idxBizFanHealthIndex.setANOMALY(0.0); idxBizFanHealthIndex.setANOMALY(0.0);
} else { } else {
idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i)); idxBizFanHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
} }
idxBizFanHealthIndex.setANALYSISTIME(DateUtils.getDateNowString()); idxBizFanHealthIndex.setANALYSISTIME(DateUtils.getDateNowString());
idxBizFanHealthIndexs.add(idxBizFanHealthIndex); idxBizFanHealthIndexs.add(idxBizFanHealthIndex);
...@@ -2395,7 +2410,7 @@ public class CommonServiceImpl { ...@@ -2395,7 +2410,7 @@ public class CommonServiceImpl {
fanHealthIndex.setRecDate(DateUtil.now()); fanHealthIndex.setRecDate(DateUtil.now());
fanHealthIndex.setArea(idxBizFanHealthIndex.getArae()); fanHealthIndex.setArea(idxBizFanHealthIndex.getArae());
fanHealthIndex.setAnalysisTime(DateUtil.now()); fanHealthIndex.setAnalysisTime(DateUtil.now());
fanHealthIndex.setHealthLevel(fanHealthIndex.getHealthLevel()); fanHealthIndex.setHealthLevel(idxBizFanHealthIndex.getHealthLevel());
fanHealthIndex.setKks(idxBizFanHealthIndex.getKks()); fanHealthIndex.setKks(idxBizFanHealthIndex.getKks());
fanHealthIndex.setRecDate(format); fanHealthIndex.setRecDate(format);
fanHealthIndex.setOrgCode(obj.getOrgCode()); fanHealthIndex.setOrgCode(obj.getOrgCode());
...@@ -2406,7 +2421,6 @@ public class CommonServiceImpl { ...@@ -2406,7 +2421,6 @@ public class CommonServiceImpl {
// idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs); // idxBizFanHealthIndexService.saveBatch(idxBizFanHealthIndexs);
// 按时刻相关数据插入TDEngine 【异步】 // 按时刻相关数据插入TDEngine 【异步】
insertFanDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName()); insertFanDataTDEngine(fanHealthIndices1, format, WarningPeriodEnum.MINUTES.getName());
} }
try { try {
...@@ -2417,7 +2431,7 @@ public class CommonServiceImpl { ...@@ -2417,7 +2431,7 @@ public class CommonServiceImpl {
// healthStatusIndicatorService.healthWarningMinute(calendar, time); // healthStatusIndicatorService.healthWarningMinute(calendar, time);
// ++++++++++ // ++++++++++
healthStatusIndicatorService.healthWarningMinute(time,gatewayId); healthStatusIndicatorService.healthWarningMinute(time, gatewayId);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -2462,61 +2476,34 @@ public class CommonServiceImpl { ...@@ -2462,61 +2476,34 @@ public class CommonServiceImpl {
// Date time = new Date(); // Date time = new Date();
// time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10); // time = DateUtil.offsetMinute(time, -DateUtil.minute(time) % 10);
String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00"); String format = DateUtil.format(time, "yyyy-MM-dd HH:mm:00");
//time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00"); // time = DateUtil.parse(format, "yyyy-MM-dd HH:mm:00");
logger.info("光伏---------------------健康指数时间----" + time); logger.info("光伏---------------------健康指数时间----" + time);
List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper List<IdxBizPvPointProcessVariableClassificationDto> data = idxBizPvPointProcessVariableClassificationMapper
.getInfluxDBData(); .getInfluxDBData();
Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream() Map<String, List<IdxBizPvPointProcessVariableClassificationDto>> maps = data.stream()
.collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId)); .collect(Collectors.groupingBy(IdxBizPvPointProcessVariableClassificationDto::getGatewayId));
// BoolQueryBuilder boolMustAll = QueryBuilders.boolQuery();
// List<QueryBuilder> should = boolMustAll.should();
List<IndicatorData> indicatorDataListAll = new LinkedList<>(); List<IndicatorData> indicatorDataListAll = new LinkedList<>();
for (String s : maps.keySet()) { for (String s : maps.keySet()) {
// BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
// String addressids = maps.get(s).stream().map(idxBizPvPointProcessVariableClassificationDto -> "\'" + idxBizPvPointProcessVariableClassificationDto.getIndexAddress() + "\'").collect(Collectors.joining(","));
List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddress(s); List<IndicatorData> indicatorDataList = indicatorDataMapper.selectDataByGatewayIdAndAddress(s);
indicatorDataListAll.addAll(indicatorDataList); indicatorDataListAll.addAll(indicatorDataList);
// List<String> address = maps.get(s).stream().map(IdxBizPvPointProcessVariableClassificationDto::getIndexAddress).collect(Collectors.toList());
// boolQueryBuilder.must(QueryBuilders.termsQuery("address.keyword", address)).must(QueryBuilders.termsQuery("gatewayId.keyword", s));
// should.add(boolQueryBuilder);
} }
// 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// //过滤条件
// .withQuery(boolMustAll);
// List<ESEquipments> equipments = new LinkedList<>();
// long totle = 0;
// try {
// SearchHits<ESEquipments> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESEquipments.class);
//
// for (SearchHit searchHit : searchHits.getSearchHits()) {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESEquipments eSAlertCalled = JSONObject.toJavaObject(jsonObject, ESEquipments.class);
// equipments.add(eSAlertCalled);
// }
// totle = searchHits.getTotalHits();
// } catch (Exception e) {
// // TODO: handle exception
// }
Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream() Map<String, Float> indicatorDataListAllMap = indicatorDataListAll.stream()
.collect(Collectors.toMap( .collect(Collectors.toMap(
indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(), indicatorData -> indicatorData.getAddress() + "_" + indicatorData.getGatewayId(),
IndicatorData::getValueF, IndicatorData::getValueF, (value1, value2) -> value1));
(value1, value2) -> value1));
HashMap<String, Double> idxBizPvPointProcessVariableClassificationDtoIdValueMap = new HashMap<>(); HashMap<String, Double> idxBizPvPointProcessVariableClassificationDtoIdValueMap = new HashMap<>();
for (IdxBizPvPointProcessVariableClassificationDto datum : data) { for (IdxBizPvPointProcessVariableClassificationDto datum : data) {
// for (ESEquipments equipment : equipments) { Float f = indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId());
// if (equipment.getAddress().equals(datum.getIndexAddress()) && equipment.getGatewayId().equals(datum.getGatewayId())) { if (f == null) {
Double currentValue = Double f = 0.0f;
.valueOf(indicatorDataListAllMap.get(datum.getIndexAddress() + "_" + datum.getGatewayId())); }
Double currentValue = Double.valueOf(f);
if (!ObjectUtils.isEmpty(currentValue)) { if (!ObjectUtils.isEmpty(currentValue)) {
datum.setCurrentValue(currentValue); datum.setCurrentValue(currentValue);
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue); idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), currentValue);
} else { } else {
idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), 0.0); idxBizPvPointProcessVariableClassificationDtoIdValueMap.put(datum.getSequenceNbr(), 0.0);
} }
// }
// }
} }
LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<IdxBizPvPointVarCentralValue> wrapper = new LambdaQueryWrapper<>();
List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper); List<IdxBizPvPointVarCentralValue> idxBizUhefs = idxBizPvPointVarCentralValueMapper.selectList(wrapper);
...@@ -2559,6 +2546,9 @@ public class CommonServiceImpl { ...@@ -2559,6 +2546,9 @@ public class CommonServiceImpl {
} }
}); });
for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) { for (IdxBizPvPointVarCentralValue idxBizUhef : idxBizUhefs) {
if (idxBizUhef == null) {
continue;
}
double value1 = 0.00; double value1 = 0.00;
double value2 = 0.00; double value2 = 0.00;
double value3 = 0.00; double value3 = 0.00;
...@@ -2676,14 +2666,15 @@ public class CommonServiceImpl { ...@@ -2676,14 +2666,15 @@ public class CommonServiceImpl {
idxBizPvHealthIndex.setRecDate(time); idxBizPvHealthIndex.setRecDate(time);
idxBizPvHealthIndex.setWeigth(1.0); idxBizPvHealthIndex.setWeigth(1.0);
// 获取健康指数对应等级 // 获取健康指数对应等级
for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) { for (IdxBizPvHealthLevel idxBizFanHealthLevel : idxBizFanHealthLevels) {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) > idxBizFanHealthLevel.getGroupLowerLimit()) { && indexValueArray.getDoubleValue(i) > idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
} }
} }
if (idxBizPvHealthIndex.getHealthIndex() == 0 && idxBizPvHealthIndex.getHealthLevel() == null) {
idxBizPvHealthIndex.setHealthLevel("危险");
}
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName()); idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点"); idxBizPvHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i)); idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
...@@ -2944,9 +2935,11 @@ public class CommonServiceImpl { ...@@ -2944,9 +2935,11 @@ public class CommonServiceImpl {
if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit() if (indexValueArray.getDoubleValue(i) <= idxBizFanHealthLevel.getGroupUpperLimit()
&& indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) { && indexValueArray.getDoubleValue(i) >= idxBizFanHealthLevel.getGroupLowerLimit()) {
idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel()); idxBizPvHealthIndex.setHealthLevel(idxBizFanHealthLevel.getHealthLevel());
} }
} }
if (idxBizPvHealthIndex.getHealthIndex() == 0 && idxBizPvHealthIndex.getHealthLevel() == null) {
idxBizPvHealthIndex.setHealthLevel("危险");
}
idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName()); idxBizPvHealthIndex.setAnalysisType(WarningPeriodEnum.MINUTES.getName());
idxBizPvHealthIndex.setAnalysisObjType("测点"); idxBizPvHealthIndex.setAnalysisObjType("测点");
idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i)); idxBizPvHealthIndex.setANOMALY(scoreValueArray.getDoubleValue(i));
...@@ -2956,7 +2949,6 @@ public class CommonServiceImpl { ...@@ -2956,7 +2949,6 @@ public class CommonServiceImpl {
BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex); BeanUtil.copyProperties(idxBizPvHealthIndex, pvHealthIndex);
pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth()); pvHealthIndex.setWeight(idxBizPvHealthIndex.getWeigth());
pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY()); pvHealthIndex.setAnomaly(idxBizPvHealthIndex.getANOMALY());
pvHealthIndex.setRecDate(DateUtil.now());
pvHealthIndex.setArea(idxBizPvHealthIndex.getArae()); pvHealthIndex.setArea(idxBizPvHealthIndex.getArae());
pvHealthIndex.setAnalysisTime(DateUtil.now()); pvHealthIndex.setAnalysisTime(DateUtil.now());
pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel()); pvHealthIndex.setHealthLevel(idxBizPvHealthIndex.getHealthLevel());
...@@ -2979,7 +2971,7 @@ public class CommonServiceImpl { ...@@ -2979,7 +2971,7 @@ public class CommonServiceImpl {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// healthStatusIndicatorService.healthWarningMinuteGF(calendar, time); // healthStatusIndicatorService.healthWarningMinuteGF(calendar, time);
healthStatusIndicatorService.healthWarningMinuteGF(time,gatewayId); healthStatusIndicatorService.healthWarningMinuteGF(time, gatewayId);
} }
/** /**
......
...@@ -34,7 +34,7 @@ spring.redis.host=10.20.1.210 ...@@ -34,7 +34,7 @@ spring.redis.host=10.20.1.210
spring.redis.port=6379 spring.redis.port=6379
spring.redis.password=yeejoin@2020 spring.redis.password=yeejoin@2020
openHealth=false openHealth=true
spring.cache.type=GENERIC spring.cache.type=GENERIC
j2cache.open-spring-cache=true j2cache.open-spring-cache=true
j2cache.cache-clean-mode=passive j2cache.cache-clean-mode=passive
......
...@@ -173,6 +173,8 @@ ...@@ -173,6 +173,8 @@
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if> <if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDateTs!= null and dto.endDateTs!= '' "> and ts &lt;= #{dto.endDateTs} </if> <if test="dto.endDateTs!= null and dto.endDateTs!= '' "> and ts &lt;= #{dto.endDateTs} </if>
<if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if> <if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if>
<!--<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>-->
<if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if> <if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if> <if test="dto.number!= null and dto.number!= ''"> AND `number` = #{dto.number} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if> <if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......
...@@ -205,6 +205,8 @@ ...@@ -205,6 +205,8 @@
<if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if> <if test="dto.analysisType!= null and dto.analysisType!= ''">and analysis_type = #{dto.analysisType}</if>
<if test="dto.endDateTs!= null and dto.endDateTs!= ''"> and ts &lt;= #{dto.endDateTs} </if> <if test="dto.endDateTs!= null and dto.endDateTs!= ''"> and ts &lt;= #{dto.endDateTs} </if>
<if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if> <if test="dto.startDateTs!= null and dto.startDateTs!= ''"> and ts &gt;= #{dto.startDateTs} </if>
<!--<if test="dto.endDate!= null and dto.endDate!= ''"> and ts &lt;= #{dto.endDate} </if>
<if test="dto.startDate!= null and dto.startDate!= ''"> and ts &gt;= #{dto.startDate} </if>-->
<if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if> <if test="dto.area!= null and dto.area!= ''"> AND area = #{dto.area} </if>
<if test="dto.subarray!= null and dto.subarray!= ''"> AND subarray = #{dto.subarray} </if> <if test="dto.subarray!= null and dto.subarray!= ''"> AND subarray = #{dto.subarray} </if>
<if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if> <if test="dto.pointName!= null and dto.pointName!= ''">AND point_name = #{dto.pointName} </if>
......
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