前置联调
This commit is contained in:
@@ -2,6 +2,7 @@ package com.njcn.dataProcess.controller;//package com.njcn.message.websocket;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||||
@@ -14,6 +15,8 @@ import com.njcn.dataProcess.api.DataVFeignClient;
|
|||||||
import com.njcn.dataProcess.service.IDataV;
|
import com.njcn.dataProcess.service.IDataV;
|
||||||
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
import com.njcn.device.biz.commApi.CommTerminalGeneralClient;
|
||||||
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
import com.njcn.device.biz.pojo.dto.LineDevGetDTO;
|
||||||
|
import com.njcn.device.pq.api.DeviceFeignClient;
|
||||||
|
import com.njcn.device.pq.pojo.dto.DeviceDTO;
|
||||||
import com.njcn.message.api.ProduceFeignClient;
|
import com.njcn.message.api.ProduceFeignClient;
|
||||||
import com.njcn.message.message.RecallMessage;
|
import com.njcn.message.message.RecallMessage;
|
||||||
import com.njcn.middle.rocket.domain.BaseMessage;
|
import com.njcn.middle.rocket.domain.BaseMessage;
|
||||||
@@ -34,6 +37,7 @@ import java.time.LocalTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@@ -52,6 +56,7 @@ public class DataRecallController extends BaseController {
|
|||||||
private IDataV dataVQuery;
|
private IDataV dataVQuery;
|
||||||
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
private final CommTerminalGeneralClient commTerminalGeneralClient;
|
||||||
private final ProduceFeignClient produceFeignClient;
|
private final ProduceFeignClient produceFeignClient;
|
||||||
|
private final DeviceFeignClient deviceFeignClient;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -62,10 +67,9 @@ public class DataRecallController extends BaseController {
|
|||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@ApiOperation("数据补招")
|
@ApiOperation("数据补招")
|
||||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||||
public HttpResult<Boolean> recall(@RequestBody RecallMessage param) {
|
public HttpResult<List<String>> recall(@RequestBody RecallMessage param) {
|
||||||
String methodDescribe = getMethodDescribe("recall");
|
String methodDescribe = getMethodDescribe("recall");
|
||||||
RecallMessage message = new RecallMessage();
|
List<String> guidList = new ArrayList<>();
|
||||||
|
|
||||||
if(CollectionUtils.isEmpty(param.getData())){
|
if(CollectionUtils.isEmpty(param.getData())){
|
||||||
|
|
||||||
List<String> runMonitorIds = new ArrayList<>();
|
List<String> runMonitorIds = new ArrayList<>();
|
||||||
@@ -81,6 +85,9 @@ public class DataRecallController extends BaseController {
|
|||||||
LocalDate finalCurrentDate = currentDate;
|
LocalDate finalCurrentDate = currentDate;
|
||||||
runMonitorIds.forEach(temp->{
|
runMonitorIds.forEach(temp->{
|
||||||
LineDevGetDTO data = commTerminalGeneralClient.getMonitorDetail(temp).getData();
|
LineDevGetDTO data = commTerminalGeneralClient.getMonitorDetail(temp).getData();
|
||||||
|
//后续根据不同前置下的测点发送补招密令
|
||||||
|
DeviceDTO data2 = deviceFeignClient.getDeviceInfo(data.getDevId()).getData();
|
||||||
|
|
||||||
Integer timeInterval = data.getTimeInterval();
|
Integer timeInterval = data.getTimeInterval();
|
||||||
List<LocalDateTime> localDateTimeList = generateTimeIntervals(finalCurrentDate, timeInterval);
|
List<LocalDateTime> localDateTimeList = generateTimeIntervals(finalCurrentDate, timeInterval);
|
||||||
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format(finalCurrentDate, DatePattern.NORM_DATE_PATTERN));
|
List<LocalDateTime> data1 = dataVQuery.monitoringTime(temp, LocalDateTimeUtil.format(finalCurrentDate, DatePattern.NORM_DATE_PATTERN));
|
||||||
@@ -91,7 +98,7 @@ public class DataRecallController extends BaseController {
|
|||||||
recallDTO.setDataType("0");
|
recallDTO.setDataType("0");
|
||||||
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
|
recallDTO.setMonitorId(Stream.of(temp).collect(Collectors.toList()));
|
||||||
recallDTO.setTimeInterval(timePeriod);
|
recallDTO.setTimeInterval(timePeriod);
|
||||||
|
recallDTO.setNodeId(data2.getNodeId());
|
||||||
recallDTOList.add(recallDTO);
|
recallDTOList.add(recallDTO);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -100,18 +107,36 @@ public class DataRecallController extends BaseController {
|
|||||||
|
|
||||||
|
|
||||||
if(!CollectionUtils.isEmpty(recallDTOList)){
|
if(!CollectionUtils.isEmpty(recallDTOList)){
|
||||||
|
Map<String, List<RecallMessage.RecallDTO>> collect = recallDTOList.stream().collect(Collectors.groupingBy(RecallMessage.RecallDTO::getNodeId));
|
||||||
|
|
||||||
|
collect.forEach((k,v)->{
|
||||||
|
RecallMessage message = new RecallMessage();
|
||||||
|
message.setNodeId(k);
|
||||||
|
message.setData(v);
|
||||||
|
String guid = IdUtil.simpleUUID();
|
||||||
|
message.setGuid(guid);
|
||||||
|
produceFeignClient.recall(message);
|
||||||
|
guidList.add(guid);
|
||||||
|
});
|
||||||
|
|
||||||
message.setData(recallDTOList);
|
|
||||||
|
|
||||||
produceFeignClient.recall(message);
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
message.setData(param.getData());
|
Map<String, List<RecallMessage.RecallDTO>> collect = param.getData().stream().collect(Collectors.groupingBy(RecallMessage.RecallDTO::getNodeId));
|
||||||
produceFeignClient.recall(message);
|
|
||||||
|
collect.forEach((k,v)->{
|
||||||
|
RecallMessage message = new RecallMessage();
|
||||||
|
message.setNodeId(k);
|
||||||
|
message.setData(v);
|
||||||
|
String guid = IdUtil.simpleUUID();
|
||||||
|
message.setGuid(guid);
|
||||||
|
produceFeignClient.recall(message);
|
||||||
|
guidList.add(guid);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, guidList, methodDescribe);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class RecallMessage {
|
|||||||
private String nodeId;
|
private String nodeId;
|
||||||
|
|
||||||
private List<String> monitorId;
|
private List<String> monitorId;
|
||||||
|
private String guid;
|
||||||
private List<RecallDTO> data;
|
private List<RecallDTO> data;
|
||||||
@Data
|
@Data
|
||||||
public static class RecallDTO {
|
public static class RecallDTO {
|
||||||
@@ -41,6 +41,7 @@ public class RecallMessage {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty("0/1(稳态/暂态)")
|
@ApiModelProperty("0/1(稳态/暂态)")
|
||||||
private String dataType;
|
private String dataType;
|
||||||
|
private String nodeId;
|
||||||
private List<String> monitorId;
|
private List<String> monitorId;
|
||||||
private List<String> timeInterval;
|
private List<String> timeInterval;
|
||||||
|
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class TopicReplyConsumer extends EnhanceConsumerMessageHandler<TopicReply
|
|||||||
@Override
|
@Override
|
||||||
protected void handleMessage(TopicReplyDTO message) {
|
protected void handleMessage(TopicReplyDTO message) {
|
||||||
//业务处理
|
//业务处理
|
||||||
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getGuid()),message.getResult(),60*60L);
|
redisUtil.saveByKeyWithExpire(RedisKeyPrefix.TOPIC_REPLY.concat(message.getGuid()),JSONObject.toJSONString(message),60*60L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user