Commit b861dac4 authored by wujiang's avatar wujiang

Merge branch 'developer' of http://36.40.66.175:5000/moa/jxdj_zx/amos-boot-zx-biz into developer

parents caad4362 b520ef6e
...@@ -41,6 +41,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -41,6 +41,9 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -75,12 +78,19 @@ public class TdInfoQueryController extends BaseController { ...@@ -75,12 +78,19 @@ public class TdInfoQueryController extends BaseController {
@Autowired @Autowired
UserEmpowerMapper userEmpowerMapper; UserEmpowerMapper userEmpowerMapper;
private SimpleDateFormat hhmmss = new SimpleDateFormat("HH:mm:ss");
private SimpleDateFormat mmss = new SimpleDateFormat("mm:ss");
private SimpleDateFormat ss = new SimpleDateFormat("ss");
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/getFanHealthIndexInfo") @PostMapping(value = "/getFanHealthIndexInfo")
@ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电") @ApiOperation(httpMethod = "POST", value = "分页查询健康指数信息 - 风电", notes = "分页查询健康指数信息 - 风电")
@GatewayIdAutowired @GatewayIdAutowired
public ResponseModel<Page<FanHealthIndex>> getFanHealthIndexInfo(@RequestBody FanHealthIndexDto dto) throws ParseException { public ResponseModel<Page<FanHealthIndex>> getFanHealthIndexInfo(@RequestBody FanHealthIndexDto dto) throws ParseException {
ReginParams reginParams = getSelectedOrgInfo(); ReginParams reginParams = getSelectedOrgInfo();
String userId = reginParams.getUserModel().getUserId(); String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH")); StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
...@@ -89,14 +99,37 @@ public class TdInfoQueryController extends BaseController { ...@@ -89,14 +99,37 @@ public class TdInfoQueryController extends BaseController {
orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%"; orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%";
} }
dto.setOrgCode(orgCode); dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) { if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate(); String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
startDate = startDate + " " + hhmmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":" + mmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":" + ss.format(currentDate);
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN); Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN); String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString); dto.setStartDate(startDateString);
} }
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) { if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate(); String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
endDate = endDate + " " + hhmmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":" + mmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":" + ss.format(currentDate);
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN); Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN); String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString); dto.setEndDate(endDateString);
...@@ -165,14 +198,39 @@ public class TdInfoQueryController extends BaseController { ...@@ -165,14 +198,39 @@ public class TdInfoQueryController extends BaseController {
orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%"; orgCode = stdUserEmpower.getAmosOrgCode().get(0)+"%";
} }
dto.setOrgCode(orgCode); dto.setOrgCode(orgCode);
Date currentDate = new Date();
if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) { if (CharSequenceUtil.isNotEmpty(dto.getStartDate())) {
String startDate = dto.getStartDate(); String startDate = dto.getStartDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && startDate.length() == 10) {
startDate = startDate + " " + hhmmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && startDate.length() == 13) {
startDate = startDate + ":" + mmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && startDate.length() == 16) {
startDate = startDate + ":" + ss.format(currentDate);
}
Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN); Date date = DateUtils.dateParse(startDate, DATE_TIME_PATTERN);
String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN); String startDateString = DateUtils.dateFormat(DateUtils.dateAddHours(date, -8), DATE_TIME_PATTERN);
dto.setStartDate(startDateString); dto.setStartDate(startDateString);
} }
if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) { if (CharSequenceUtil.isNotEmpty(dto.getEndDate())) {
String endDate = dto.getEndDate(); String endDate = dto.getEndDate();
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按天") && endDate.length() == 10) {
endDate = endDate + " " + hhmmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按小时") && endDate.length() == 13) {
endDate = endDate + ":" + mmss.format(currentDate);
}
if(dto.getAnalysisType() != null && dto.getAnalysisType().equals("按10分钟") && endDate.length() == 16) {
endDate = endDate + ":" + ss.format(currentDate);
}
Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN); Date endDateDate = DateUtils.dateParse(endDate, DATE_TIME_PATTERN);
String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN); String endDateString = DateUtils.dateFormat(DateUtils.dateAddHours(endDateDate, -8), DATE_TIME_PATTERN);
dto.setEndDate(endDateString); dto.setEndDate(endDateString);
......
...@@ -16,11 +16,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*; ...@@ -16,11 +16,13 @@ import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.*;
import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper; import com.yeejoin.amos.boot.module.jxiop.biz.tdmapper.IndicatorDataMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment; import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.typroject.tyboot.component.emq.EmqKeeper;
import tech.tablesaw.api.ColumnType; import tech.tablesaw.api.ColumnType;
import tech.tablesaw.api.DoubleColumn; import tech.tablesaw.api.DoubleColumn;
import tech.tablesaw.api.Table; import tech.tablesaw.api.Table;
...@@ -90,6 +92,9 @@ public class KafkaConsumerService { ...@@ -90,6 +92,9 @@ public class KafkaConsumerService {
@Value("${last.month.num:12}") @Value("${last.month.num:12}")
private Integer lastMonthNum; private Integer lastMonthNum;
@Autowired
EmqKeeper emqKeeper;
ExecutorService service = Executors.newFixedThreadPool(threadNum); ExecutorService service = Executors.newFixedThreadPool(threadNum);
BlockingQueue<PointData> queue = new LinkedBlockingQueue<>(); BlockingQueue<PointData> queue = new LinkedBlockingQueue<>();
...@@ -567,6 +572,13 @@ public class KafkaConsumerService { ...@@ -567,6 +572,13 @@ public class KafkaConsumerService {
resultMap.put("processVariable", data1); resultMap.put("processVariable", data1);
resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", fanPointVarCorrelation.getSequenceNbr());
if (fanPointVarCorrelation.getEquipmentName().equals("升压站")){
try {
emqKeeper.getMqttClient().publish("gkblfx",JSON.toJSONString(resultMap).getBytes(), 2 ,false);
} catch (MqttException e) {
e.printStackTrace();
}
}
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute() String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute()
.body(); .body();
...@@ -606,7 +618,7 @@ public class KafkaConsumerService { ...@@ -606,7 +618,7 @@ public class KafkaConsumerService {
* @param consumerRecords messages * @param consumerRecords messages
* @param ack ack * @param ack ack
*/ */
@KafkaListener(id = "GKHFPvConsumer", groupId = "consumerGroup", topics = kafkaTopicConsumerGKHFPv) @KafkaListener(id = "GKHFPvConsume12r", groupId = "consumerGroup", topics = kafkaTopicConsumerGKHFPv)
public void listenGKHFPv(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack) { public void listenGKHFPv(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack) {
try { try {
...@@ -653,7 +665,14 @@ public class KafkaConsumerService { ...@@ -653,7 +665,14 @@ public class KafkaConsumerService {
double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray(); double[] data1 = table.where(selection).doubleColumn("value").asDoubleArray();
resultMap.put("processVariable", data1); resultMap.put("processVariable", data1);
resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr()); resultMap.put("processVariableId", pvPointVarCorrelation.getSequenceNbr());
if (pvPointVarCorrelation.getEquipmentName().equals("升压站")){
System.out.println("升压站数据进来了");
try {
emqKeeper.getMqttClient().publish("gkblfx",JSON.toJSONString(resultMap).getBytes(), 2 ,false);
} catch (MqttException e) {
e.printStackTrace();
}
}
String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute() String response = HttpUtil.createPost(baseUrlGKHF).body(JSON.toJSONString(resultMap)).execute()
.body(); .body();
......
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