24 Commits

Author SHA1 Message Date
hzj
bdcdf51769 冀北版本过滤无效数据 2026-07-24 09:06:41 +08:00
hzj
bdf39dc8a6 Merge remote-tracking branch 'origin/master' into master-jb 2026-07-22 16:30:28 +08:00
hzj
73004aafa7 Merge remote-tracking branch 'origin/master' 2026-07-22 16:29:03 +08:00
hzj
edbf2606f6 消息数据过滤 2026-07-22 16:28:26 +08:00
wr
d12571400f 微调 2026-07-22 16:27:13 +08:00
hzj
6963a29852 Merge branch 'master-jb' of http://192.168.1.22:3000/Middleware/cn-data-platform into master-jb
# Conflicts:
#	algorithm/algorithm-boot/src/main/java/com/njcn/algorithm/serviceimpl/line/IDataOnlineRateServiceImpl.java
2026-07-22 16:16:45 +08:00
hzj
441a777bf9 冀北版本过滤无效数据 2026-07-22 16:12:46 +08:00
hzj
14b213fb99 Revert "冀北版本过滤无效数据"
This reverts commit c1a2f3e8fb.
2026-07-22 16:04:57 +08:00
hzj
c1a2f3e8fb 冀北版本过滤无效数据 2026-07-22 15:58:15 +08:00
hzj
eb70a9df2f Merge remote-tracking branch 'origin/master' into master-jb 2026-07-22 11:02:27 +08:00
73a316d7fb 综合评估算法调整 2026-07-16 09:00:45 +08:00
cdf
c0e686d540 添加前置类型 2026-07-15 13:15:10 +08:00
xy
274d787b04 refactor(data): 统一数据库字段命名规范并更新查询逻辑
- 将DataHarmpowerP类中的totPf、totDf、totP等字段的@Column注解名称规范化为下划线格式
- 将DataHarmpowerP类中的totP1-totP50字段名统一调整为tot_tp_1-tot_tp_50格式
- 将DataHarmpowerQ类中的totQ字段名调整为tot_q,totQ1-totQ50调整为tot_tq_1-tot_tq_50格式
- 将DataHarmpowerS类中的totS字段名调整为tot_s,totS1-totS50调整为tot_ts_1-tot_ts_50格式
- 在InfluxdbDataHarmpowerPImpl服务中添加tot_tp_1-tot_tp_50字段的查询条件配置
- 在InfluxdbDataHarmpowerPImpl服务中增加TotP、TotDf、TotPf字段的选择查询
- 在InfluxdbDataHarmpowerQImpl服务中添加tot_tq_1-tot_tq_50字段的查询条件配置
- 在InfluxdbDataHarmpowerQImpl服务中增加TotQ字段的选择查询
- 在InfluxdbDataHarmpowerSImpl服务中添加tot_ts_1-tot_ts_50字段的查询条件配置
- 在InfluxdbDataHarmpowerSImpl服务中增加TotS字段的选择查询
2026-07-01 17:16:21 +08:00
ac40e92c79 专项分析调整,综合评估调整 2026-06-30 18:21:53 +08:00
88cd32dd10 专项分析调整,综合评估调整 2026-06-30 15:57:50 +08:00
c5c4f6e31b Merge: mq-starter Phase2 message 切片接入(方案A)
Task9 切片(FrontDataMqListener LN_Topic 上行 / RecallMqSender Recall 下行, legacy 按 mq.type 互斥, rocketmq 缺省不变不双消费) + 真实 autoconfig 顺序 wiring 测试; 配套 mq-starter 装配顺序修复(@AutoConfigureBefore)+护栏已推 Gitea(9f6ffad..e599171); 最终全分支 review(opus) 无 Critical.
2026-06-29 14:11:40 +08:00
79374ea6ec test(message): 切片 wiring 测试改用真实 autoconfig 顺序
MqSliceWiringTest 从 withUserConfiguration 手动排序改为 AutoConfigurations.of
(等价真实 boot 的 AutoConfigurationSorter),并断言 MqTemplate / MqListenerRegistry
在真实顺序下装配,防止 core 装配顺序回归;配合 mq-starter driver autoconfig 的
@AutoConfigureBefore 修复。同时去掉 driver 选择用例多余的 Redis 守卫。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-29 12:01:49 +08:00
0b950b3c35 feat(message-boot): 接入 mq-starter 通用 MQ 抽象层(Task 9)
- 新增 FrontDataMqListener:@MqListener(LN_Topic),仅 redis-stream 模式激活
- 新增 RecallMqSender:MqTemplate.send 下行下发 Recall 消息
- FrontDataConsumer 加 @ConditionalOnProperty(mq.type=rocketmq, matchIfMissing=true) 互斥保护
- 新增 MqSliceWiringTest:4 个 ApplicationContextRunner 切片测试,全部通过
  - 关键修复:用 withUserConfiguration(依赖顺序列举) 替代 AutoConfigurations.of(),
    避免字母序排序导致 MqCoreAutoConfiguration 在 driver autoconfig 前处理,
    @ConditionalOnBean(MqDriver.class) 因此失败

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-29 11:16:02 +08:00
hzj
217efae032 Merge remote-tracking branch 'origin/master' into master-jb 2026-06-09 16:22:19 +08:00
wr
37959a4a7e 微调 2026-05-27 10:56:01 +08:00
hzj
adc3dbfb26 Merge remote-tracking branch 'origin/master' into master-jb 2026-05-21 14:34:04 +08:00
hzj
846a21c814 Merge remote-tracking branch 'origin/master' into master-jb 2026-05-15 09:20:49 +08:00
2d07a60001 Merge pull request 'master-temp' (#2) from master-temp into master-jb
Reviewed-on: #2
2026-05-15 09:19:38 +08:00
hzj
e982fa960e 冀北版本适配 2026-05-09 08:43:57 +08:00
32 changed files with 534 additions and 210 deletions

View File

@@ -51,6 +51,12 @@ public class DataComAssServiceImpl implements IDataComAssService {
@Resource @Resource
private PqDataVerifyFeignClient pqDataVerifyFeignClient; private PqDataVerifyFeignClient pqDataVerifyFeignClient;
/**
* 查询配置 辽宁版本比较特殊没有CP95值采用平均值进行判断
*/
@Value("${version.used:master}")
private String versionUsed;
@Override @Override
public void dataComAssHandler(CalculatedParam calculatedParam) { public void dataComAssHandler(CalculatedParam calculatedParam) {
List<DataComassesDPO> list = new ArrayList<>(); List<DataComassesDPO> list = new ArrayList<>();
@@ -138,7 +144,7 @@ public class DataComAssServiceImpl implements IDataComAssService {
BigDecimal hundred = BigDecimal.valueOf(100); BigDecimal hundred = BigDecimal.valueOf(100);
//************************************电压偏差******************************************** //************************************电压偏差********************************************
lineParam.setPhasicType(Arrays.asList("A", "B", "C")); lineParam.setPhasicType(Arrays.asList("A", "B", "C"));
lineParam.setValueType(Arrays.asList("AVG")); lineParam.setValueType(Collections.singletonList("AVG"));
lineParam.setColumnName("vu_dev"); lineParam.setColumnName("vu_dev");
lineParam.setGe("10"); lineParam.setGe("10");
Integer vuDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer vuDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData();
@@ -169,6 +175,7 @@ public class DataComAssServiceImpl implements IDataComAssService {
//************************************频率偏差******************************************** //************************************频率偏差********************************************
lineParam.setColumnName("freq_dev"); lineParam.setColumnName("freq_dev");
lineParam.setGe("0.3"); lineParam.setGe("0.3");
lineParam.setLt(null);
Integer freqDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer freqDev1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData();
lineParam.setGe("0.2"); lineParam.setGe("0.2");
@@ -196,8 +203,15 @@ public class DataComAssServiceImpl implements IDataComAssService {
} }
//************************************谐波畸变率******************************************** //************************************谐波畸变率********************************************
lineParam.setColumnName("v_thd"); lineParam.setColumnName("v_thd");
lineParam.setValueType(Arrays.asList("CP95"));
if("liaoning".equals(versionUsed)){
lineParam.setValueType(Collections.singletonList("AVG"));
}else {
lineParam.setValueType(Collections.singletonList("CP95"));
}
lineParam.setGe("6"); lineParam.setGe("6");
lineParam.setLt(null);
Integer vThd1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer vThd1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData();
lineParam.setGe("4"); lineParam.setGe("4");
@@ -226,7 +240,12 @@ public class DataComAssServiceImpl implements IDataComAssService {
//************************************三相电压不平衡度******************************************** //************************************三相电压不平衡度********************************************
lineParam.setColumnName("v_unbalance"); lineParam.setColumnName("v_unbalance");
if("liaoning".equals(versionUsed)){
lineParam.setValueType(Collections.singletonList("MAX"));
}
lineParam.setPhasicType(Collections.singletonList("T"));
lineParam.setGe("4"); lineParam.setGe("4");
lineParam.setLt(null);
Integer vUnbalance1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer vUnbalance1 = dataVFeignClient.getColumnNameCountRawData(lineParam).getData();
lineParam.setGe("2"); lineParam.setGe("2");
@@ -255,7 +274,9 @@ public class DataComAssServiceImpl implements IDataComAssService {
//************************************电压波动(短时闪变)******************************************** //************************************电压波动(短时闪变)********************************************
lineParam.setColumnName("pst"); lineParam.setColumnName("pst");
lineParam.setValueType(null); lineParam.setValueType(null);
lineParam.setPhasicType(Arrays.asList("A", "B", "C"));
lineParam.setGe("0.8"); lineParam.setGe("0.8");
lineParam.setLt("1");
Integer plt1 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer plt1 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData();
lineParam.setGe("0.6"); lineParam.setGe("0.6");
@@ -275,11 +296,11 @@ public class DataComAssServiceImpl implements IDataComAssService {
Integer plt5 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData(); Integer plt5 = dataFlickerFeignClient.getColumnNameCountRawData(lineParam).getData();
BigDecimal pltAll = BigDecimal.valueOf(plt1 + plt2 + plt3 + plt4 + plt5); BigDecimal pltAll = BigDecimal.valueOf(plt1 + plt2 + plt3 + plt4 + plt5);
if (pltAll.compareTo(BigDecimal.ZERO) != 0) { if (pltAll.compareTo(BigDecimal.ZERO) != 0) {
outMap.put("data_plt1", BigDecimal.valueOf(plt1).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); outMap.put("data_pst1", BigDecimal.valueOf(plt1).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP));
outMap.put("data_plt2", BigDecimal.valueOf(plt2).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); outMap.put("data_pst2", BigDecimal.valueOf(plt2).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP));
outMap.put("data_plt3", BigDecimal.valueOf(plt3).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); outMap.put("data_pst3", BigDecimal.valueOf(plt3).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP));
outMap.put("data_plt4", BigDecimal.valueOf(plt4).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); outMap.put("data_pst4", BigDecimal.valueOf(plt4).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP));
outMap.put("data_plt5", BigDecimal.valueOf(plt5).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP)); outMap.put("data_pst5", BigDecimal.valueOf(plt5).multiply(hundred).divide(pltAll, 3, RoundingMode.HALF_UP));
} }
if (!CollUtil.isEmpty(outMap)) { if (!CollUtil.isEmpty(outMap)) {

View File

@@ -9,7 +9,6 @@ import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.algorithm.service.line.IDataOnlineRateService; import com.njcn.algorithm.service.line.IDataOnlineRateService;
import com.njcn.algorithm.utils.MemorySizeUtil;
import com.njcn.dataProcess.api.DataIntegrityFeignClient; import com.njcn.dataProcess.api.DataIntegrityFeignClient;
import com.njcn.dataProcess.api.DataOnlineRateFeignClient; import com.njcn.dataProcess.api.DataOnlineRateFeignClient;
import com.njcn.dataProcess.api.DataVFeignClient; import com.njcn.dataProcess.api.DataVFeignClient;
@@ -49,8 +48,8 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(IDataOnlineRateServiceImpl.class);
@Value("${line.num:10}") @Value("${line.num}")
private Integer NUM; private Integer NUM = 100;
private final Integer online = 1; private final Integer online = 1;
private final Integer offline = 0; private final Integer offline = 0;
@@ -70,8 +69,7 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
@Override @Override
public void dataOnlineRate(CalculatedParam calculatedParam) { public void dataOnlineRate(CalculatedParam calculatedParam) {
MemorySizeUtil.getNowMemory(); logger.info("{},onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now());
logger.info("{},{}onlineRate表转r_stat_onlinerate_d算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));
lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate())); lineParam.setEndTime(TimeUtils.getEndOfDay(calculatedParam.getDataDate()));
@@ -87,7 +85,7 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
Map<String, List<LineDevGetDTO>> LineDevGetMap = devList.stream() Map<String, List<LineDevGetDTO>> LineDevGetMap = devList.stream()
.filter(x -> devIdList.contains(x.getDevId())) .filter(x -> devIdList.contains(x.getDevId()))
.collect(Collectors.groupingBy(LineDevGetDTO::getDevId)); .collect(Collectors.groupingBy(LineDevGetDTO::getDevId));
if (ObjectUtil.isNotNull(calculatedParam.getType())&&calculatedParam.getType() == 1) { if (ObjectUtil.isNotNull(calculatedParam.getType()) && calculatedParam.getType() == 1) {
LineDevGetMap.forEach((key, value) -> { LineDevGetMap.forEach((key, value) -> {
DataOnlineRateDto.Detail onlineRateDpo = new DataOnlineRateDto.Detail(); DataOnlineRateDto.Detail onlineRateDpo = new DataOnlineRateDto.Detail();
List<String> collect = value.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> collect = value.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
@@ -132,9 +130,9 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
List<String> lineIds = value.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList()); List<String> lineIds = value.stream().map(LineDevGetDTO::getPointId).collect(Collectors.toList());
lineParam.setLineId(lineIds); lineParam.setLineId(lineIds);
List<DataIntegrityDto> integrityDS = dataIntegrityFeignClient.getRawData(lineParam).getData(); List<DataIntegrityDto> integrityDS = dataIntegrityFeignClient.getRawData(lineParam).getData();
Double max=0.0; Double max = 0.0;
if(CollUtil.isNotEmpty(integrityDS)){ if (CollUtil.isNotEmpty(integrityDS)) {
List<Double> info=new ArrayList<>(); List<Double> info = new ArrayList<>();
for (DataIntegrityDto integrityD : integrityDS) { for (DataIntegrityDto integrityD : integrityDS) {
double realTime = integrityD.getRealTime(); double realTime = integrityD.getRealTime();
double dueTime = integrityD.getDueTime(); double dueTime = integrityD.getDueTime();
@@ -146,7 +144,7 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
} }
max = info.stream().max(Comparator.naturalOrder()).orElse(0.0); max = info.stream().max(Comparator.naturalOrder()).orElse(0.0);
} }
int v = (int)Math.ceil(InfluxDBPublicParam.DAY_MINUTE * max); int v = (int) Math.ceil(InfluxDBPublicParam.DAY_MINUTE * max);
onlineRateDpo.setOnlineMin(v); onlineRateDpo.setOnlineMin(v);
onlineRateDpo.setOfflineMin(InfluxDBPublicParam.DAY_MINUTE - v); onlineRateDpo.setOfflineMin(InfluxDBPublicParam.DAY_MINUTE - v);
list.add(onlineRateDpo); list.add(onlineRateDpo);
@@ -249,7 +247,7 @@ public class IDataOnlineRateServiceImpl implements IDataOnlineRateService {
long differ = DateUtil.between(date, newDate, DateUnit.MINUTE); long differ = DateUtil.between(date, newDate, DateUnit.MINUTE);
if (online.equals(type)) { if (online.equals(type)) {
minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ; minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ;
}else{ } else {
minute = (int) differ; minute = (int) differ;
} }
} else { } else {

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil; import cn.hutool.core.date.LocalDateTimeUtil;
import com.njcn.algorithm.pojo.bo.CalculatedParam; import com.njcn.algorithm.pojo.bo.CalculatedParam;
import com.njcn.algorithm.service.line.IPollutionCalc; import com.njcn.algorithm.service.line.IPollutionCalc;
import com.njcn.algorithm.utils.MemorySizeUtil;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.dataProcess.api.DataHarmRateVFeignClient; import com.njcn.dataProcess.api.DataHarmRateVFeignClient;
import com.njcn.dataProcess.api.DataIFeignClient; import com.njcn.dataProcess.api.DataIFeignClient;
@@ -24,10 +25,13 @@ import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -37,6 +41,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class PollutionCalcImpl implements IPollutionCalc { public class PollutionCalcImpl implements IPollutionCalc {
private static final Logger logger = LoggerFactory.getLogger(DataCleanServiceImpl.class);
@Resource @Resource
private CommTerminalGeneralClient commTerminalGeneralClient; private CommTerminalGeneralClient commTerminalGeneralClient;
@Resource @Resource
@@ -58,7 +63,8 @@ public class PollutionCalcImpl implements IPollutionCalc {
*/ */
@Override @Override
public void calcAllLineValue(CalculatedParam calculatedParam) { public void calcAllLineValue(CalculatedParam calculatedParam) {
System.out.println("当前执行监测点污染值算法++++++++++++++++++++++++++++++++++"); MemorySizeUtil.getNowMemory();
logger.info("{},{}污染值监测点算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
List<DataPollutionD> list = new ArrayList<>(); List<DataPollutionD> list = new ArrayList<>();
List<String> idList = calculatedParam.getIdList(); List<String> idList = calculatedParam.getIdList();
List<Overlimit> overlimitList = commTerminalGeneralClient.getOverLimitDataByIds(idList).getData(); List<Overlimit> overlimitList = commTerminalGeneralClient.getOverLimitDataByIds(idList).getData();
@@ -70,7 +76,6 @@ public class PollutionCalcImpl implements IPollutionCalc {
String vHarmonicLimit = dictData.get(DicDataEnum.V_HARMONIC_LIMIT.getCode()); String vHarmonicLimit = dictData.get(DicDataEnum.V_HARMONIC_LIMIT.getCode());
String iAllLimit = dictData.get(DicDataEnum.I_ALL_LIMIT.getCode()); String iAllLimit = dictData.get(DicDataEnum.I_ALL_LIMIT.getCode());
if (CollUtil.isNotEmpty(idList)) { if (CollUtil.isNotEmpty(idList)) {
System.out.println("总共" + idList.size() + "个监测点参与污染值计算,开始执行");
DataPollutionD dataPollutionD; DataPollutionD dataPollutionD;
LineCountEvaluateParam lineParam = new LineCountEvaluateParam(); LineCountEvaluateParam lineParam = new LineCountEvaluateParam();
lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate())); lineParam.setStartTime(TimeUtils.getBeginOfDay(calculatedParam.getDataDate()));

View File

@@ -28,11 +28,14 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*; import java.util.*;
import java.util.function.BinaryOperator; import java.util.function.BinaryOperator;
import java.util.function.Function; import java.util.function.Function;
@@ -49,6 +52,7 @@ import java.util.stream.Stream;
@RequiredArgsConstructor @RequiredArgsConstructor
public class PollutionServiceImpl implements IPollutionService { public class PollutionServiceImpl implements IPollutionService {
private static final Logger logger = LoggerFactory.getLogger(DataCleanServiceImpl.class);
@Value("${line.num:10}") @Value("${line.num:10}")
private Integer NUM; private Integer NUM;
@@ -72,8 +76,8 @@ public class PollutionServiceImpl implements IPollutionService {
@Override @Override
public void handleDay(CalculatedParam<String> calculatedParam) { public void handleDay(CalculatedParam<String> calculatedParam) {
System.out.println("当前执行污区监测点算法++++++++++++++++++++++++++++++++++"); MemorySizeUtil.getNowMemory();
logger.info("{},{}污区监测点算法开始=====》", LocalDateTime.now(),calculatedParam.getDataDate());
List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_STATIS.getCode()).getData(); List<DictData> dictDataList = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.POLLUTION_STATIS.getCode()).getData();
Map<String, DictData> dictData = dictDataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity())); Map<String, DictData> dictData = dictDataList.stream().collect(Collectors.toMap(DictData::getCode, Function.identity()));
LocalDate local = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate()); LocalDate local = LocalDateTimeUtil.parseDate(calculatedParam.getDataDate());

View File

@@ -21,6 +21,7 @@ import com.njcn.device.biz.commApi.CommLineClient;
import com.njcn.device.biz.pojo.dto.LineDTO; import com.njcn.device.biz.pojo.dto.LineDTO;
import com.njcn.device.pms.pojo.param.MonitorTerminalParam; import com.njcn.device.pms.pojo.param.MonitorTerminalParam;
import com.njcn.device.pq.api.LineFeignClient; import com.njcn.device.pq.api.LineFeignClient;
import com.njcn.device.pq.api.UserLedgerFeignClient;
import com.njcn.device.pq.pojo.vo.LineDetailDataVO; import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
import com.njcn.event.api.EventDetailFeignClient; import com.njcn.event.api.EventDetailFeignClient;
import com.njcn.event.api.TransientFeignClient; import com.njcn.event.api.TransientFeignClient;
@@ -84,7 +85,7 @@ public class SpecialAnalysisServiceImpl implements ISpecialAnalysisService {
@Resource @Resource
private CommLineClient commLineClient; private CommLineClient commLineClient;
@Resource @Resource
private UserLedgerOldFeignClient userLedgerFeignClient; private UserLedgerFeignClient userLedgerFeignClient;
@Resource @Resource
private DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient; private DataLimitRateDetailFeignClient dataLimitRateDetailFeignClient;

View File

@@ -8,6 +8,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
@@ -20,10 +21,7 @@ import java.time.LocalDateTime;
@Data @Data
public class MessageHarmonicDataSet implements Serializable { public class MessageHarmonicDataSet implements Serializable {
private Integer FLAG; private Integer FLAG;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Instant TIME;
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime TIME;
private MessageV V; private MessageV V;
private MessageI I; private MessageI I;
private MessageP PQ; private MessageP PQ;

View File

@@ -24,7 +24,10 @@ import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -91,9 +94,9 @@ public class MessageAnalysisServiceImpl implements MessageAnalysisService {
String value = messageDataDTO.getValue(); String value = messageDataDTO.getValue();
if(Objects.equals(DataTypeEnum.HARMONIC.getCode(),dataType)){ if(Objects.equals(DataTypeEnum.HARMONIC.getCode(),dataType)){
MessageHarmonicDataSet messageHarmonicDataSet = JSONObject.parseObject(value, MessageHarmonicDataSet.class); MessageHarmonicDataSet messageHarmonicDataSet = JSONObject.parseObject(value, MessageHarmonicDataSet.class);
LocalDateTime localDateTime = messageHarmonicDataSet.getTIME(); LocalDateTime localDateTime = LocalDateTime.ofInstant(messageHarmonicDataSet.getTIME(), ZoneId.systemDefault());;
//排除上电下电等情况前置上送上不是整分的数据 //排除上电下电等情况前置上送上不是整分的数据
if(!(localDateTime.getSecond() == 0)){ if((localDateTime.getSecond() != 0)||localDateTime.get(ChronoField.MILLI_OF_SECOND)!=0){
return; return;
} }
Integer flag = messageHarmonicDataSet.getFLAG(); Integer flag = messageHarmonicDataSet.getFLAG();

View File

@@ -2,10 +2,7 @@ package com.njcn.dataProcess.api;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.dataProcess.api.fallback.RmpEventFeignClientFallbackFactory;
import com.njcn.dataProcess.api.fallback.SpThroughFeignClientFallbackFactory; import com.njcn.dataProcess.api.fallback.SpThroughFeignClientFallbackFactory;
import com.njcn.dataProcess.dto.RmpEventDetailDTO;
import com.njcn.dataProcess.param.LineCountEvaluateParam;
import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto; import com.njcn.dataProcess.pojo.dto.RActivePowerRangeDto;
import com.njcn.dataProcess.pojo.dto.SpThroughDto; import com.njcn.dataProcess.pojo.dto.SpThroughDto;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;

View File

@@ -214,111 +214,111 @@ public class DataHarmpowerP {
private Double p50; private Double p50;
//在线监测添加的字段 //在线监测添加的字段
@Column(name = "totPf") @Column(name = "tot_p")
private Double totPf;
@Column(name = "totDf")
private Double totDf;
@Column(name = "totP")
private Double totP; private Double totP;
@Column(name = "totP1") @Column(name = "tot_df")
private Double totDf;
@Column(name = "tot_pf")
private Double totPf;
@Column(name = "tot_tp_1")
private Double totP1; private Double totP1;
@Column(name = "totP2") @Column(name = "tot_tp_2")
private Double totP2; private Double totP2;
@Column(name = "totP3") @Column(name = "tot_tp_3")
private Double totP3; private Double totP3;
@Column(name = "totP4") @Column(name = "tot_tp_4")
private Double totP4; private Double totP4;
@Column(name = "totP5") @Column(name = "tot_tp_5")
private Double totP5; private Double totP5;
@Column(name = "totP6") @Column(name = "tot_tp_6")
private Double totP6; private Double totP6;
@Column(name = "totP7") @Column(name = "tot_tp_7")
private Double totP7; private Double totP7;
@Column(name = "totP8") @Column(name = "tot_tp_8")
private Double totP8; private Double totP8;
@Column(name = "totP9") @Column(name = "tot_tp_9")
private Double totP9; private Double totP9;
@Column(name = "totP10") @Column(name = "tot_tp_10")
private Double totP10; private Double totP10;
@Column(name = "totP11") @Column(name = "tot_tp_11")
private Double totP11; private Double totP11;
@Column(name = "totP12") @Column(name = "tot_tp_12")
private Double totP12; private Double totP12;
@Column(name = "totP13") @Column(name = "tot_tp_13")
private Double totP13; private Double totP13;
@Column(name = "totP14") @Column(name = "tot_tp_14")
private Double totP14; private Double totP14;
@Column(name = "totP15") @Column(name = "tot_tp_15")
private Double totP15; private Double totP15;
@Column(name = "totP16") @Column(name = "tot_tp_16")
private Double totP16; private Double totP16;
@Column(name = "totP17") @Column(name = "tot_tp_17")
private Double totP17; private Double totP17;
@Column(name = "totP18") @Column(name = "tot_tp_18")
private Double totP18; private Double totP18;
@Column(name = "totP19") @Column(name = "tot_tp_19")
private Double totP19; private Double totP19;
@Column(name = "totP20") @Column(name = "tot_tp_20")
private Double totP20; private Double totP20;
@Column(name = "totP21") @Column(name = "tot_tp_21")
private Double totP21; private Double totP21;
@Column(name = "totP22") @Column(name = "tot_tp_22")
private Double totP22; private Double totP22;
@Column(name = "totP23") @Column(name = "tot_tp_23")
private Double totP23; private Double totP23;
@Column(name = "totP24") @Column(name = "tot_tp_24")
private Double totP24; private Double totP24;
@Column(name = "totP25") @Column(name = "tot_tp_25")
private Double totP25; private Double totP25;
@Column(name = "totP26") @Column(name = "tot_tp_26")
private Double totP26; private Double totP26;
@Column(name = "totP27") @Column(name = "tot_tp_27")
private Double totP27; private Double totP27;
@Column(name = "totP28") @Column(name = "tot_tp_28")
private Double totP28; private Double totP28;
@Column(name = "totP29") @Column(name = "tot_tp_29")
private Double totP29; private Double totP29;
@Column(name = "totP30") @Column(name = "tot_tp_30")
private Double totP30; private Double totP30;
@Column(name = "totP31") @Column(name = "tot_tp_31")
private Double totP31; private Double totP31;
@Column(name = "totP32") @Column(name = "tot_tp_32")
private Double totP32; private Double totP32;
@Column(name = "totP33") @Column(name = "tot_tp_33")
private Double totP33; private Double totP33;
@Column(name = "totP34") @Column(name = "tot_tp_34")
private Double totP34; private Double totP34;
@Column(name = "totP35") @Column(name = "tot_tp_35")
private Double totP35; private Double totP35;
@Column(name = "totP36") @Column(name = "tot_tp_36")
private Double totP36; private Double totP36;
@Column(name = "totP37") @Column(name = "tot_tp_37")
private Double totP37; private Double totP37;
@Column(name = "totP38") @Column(name = "tot_tp_38")
private Double totP38; private Double totP38;
@Column(name = "totP39") @Column(name = "tot_tp_39")
private Double totP39; private Double totP39;
@Column(name = "totP40") @Column(name = "tot_tp_40")
private Double totP40; private Double totP40;
@Column(name = "totP41") @Column(name = "tot_tp_41")
private Double totP41; private Double totP41;
@Column(name = "totP42") @Column(name = "tot_tp_42")
private Double totP42; private Double totP42;
@Column(name = "totP43") @Column(name = "tot_tp_43")
private Double totP43; private Double totP43;
@Column(name = "totP44") @Column(name = "tot_tp_44")
private Double totP44; private Double totP44;
@Column(name = "totP45") @Column(name = "tot_tp_45")
private Double totP45; private Double totP45;
@Column(name = "totP46") @Column(name = "tot_tp_46")
private Double totP46; private Double totP46;
@Column(name = "totP47") @Column(name = "tot_tp_47")
private Double totP47; private Double totP47;
@Column(name = "totP49") @Column(name = "tot_tp_49")
private Double totP48; private Double totP48;
@Column(name = "totP49") @Column(name = "tot_tp_49")
private Double totP49; private Double totP49;
@Column(name = "totP50") @Column(name = "tot_tp_50")
private Double totP50; private Double totP50;

View File

@@ -208,107 +208,107 @@ public class DataHarmpowerQ {
private Double q50; private Double q50;
//在线监测添加的字段 //在线监测添加的字段
@Column(name = "totQ") @Column(name = "tot_q")
private Double totQ; private Double totQ;
@Column(name = "totQ1") @Column(name = "tot_tq_1")
private Double totQ1; private Double totQ1;
@Column(name = "totQ2") @Column(name = "tot_tq_2")
private Double totQ2; private Double totQ2;
@Column(name = "totQ3") @Column(name = "tot_tq_3")
private Double totQ3; private Double totQ3;
@Column(name = "totQ4") @Column(name = "tot_tq_4")
private Double totQ4; private Double totQ4;
@Column(name = "totQ5") @Column(name = "tot_tq_5")
private Double totQ5; private Double totQ5;
@Column(name = "totQ6") @Column(name = "tot_tq_6")
private Double totQ6; private Double totQ6;
@Column(name = "totQ7") @Column(name = "tot_tq_7")
private Double totQ7; private Double totQ7;
@Column(name = "totQ8") @Column(name = "tot_tq_8")
private Double totQ8; private Double totQ8;
@Column(name = "totQ9") @Column(name = "tot_tq_9")
private Double totQ9; private Double totQ9;
@Column(name = "totQ10") @Column(name = "tot_tq_10")
private Double totQ10; private Double totQ10;
@Column(name = "totQ11") @Column(name = "tot_tq_11")
private Double totQ11; private Double totQ11;
@Column(name = "totQ12") @Column(name = "tot_tq_12")
private Double totQ12; private Double totQ12;
@Column(name = "totQ13") @Column(name = "tot_tq_13")
private Double totQ13; private Double totQ13;
@Column(name = "totQ14") @Column(name = "tot_tq_14")
private Double totQ14; private Double totQ14;
@Column(name = "totQ15") @Column(name = "tot_tq_15")
private Double totQ15; private Double totQ15;
@Column(name = "totQ16") @Column(name = "tot_tq_16")
private Double totQ16; private Double totQ16;
@Column(name = "totQ17") @Column(name = "tot_tq_17")
private Double totQ17; private Double totQ17;
@Column(name = "totQ18") @Column(name = "tot_tq_18")
private Double totQ18; private Double totQ18;
@Column(name = "totQ19") @Column(name = "tot_tq_19")
private Double totQ19; private Double totQ19;
@Column(name = "totQ20") @Column(name = "tot_tq_20")
private Double totQ20; private Double totQ20;
@Column(name = "totQ21") @Column(name = "tot_tq_21")
private Double totQ21; private Double totQ21;
@Column(name = "totQ22") @Column(name = "tot_tq_22")
private Double totQ22; private Double totQ22;
@Column(name = "totQ23") @Column(name = "tot_tq_23")
private Double totQ23; private Double totQ23;
@Column(name = "totQ24") @Column(name = "tot_tq_24")
private Double totQ24; private Double totQ24;
@Column(name = "totQ25") @Column(name = "tot_tq_25")
private Double totQ25; private Double totQ25;
@Column(name = "totQ26") @Column(name = "tot_tq_26")
private Double totQ26; private Double totQ26;
@Column(name = "totQ27") @Column(name = "tot_tq_27")
private Double totQ27; private Double totQ27;
@Column(name = "totQ28") @Column(name = "tot_tq_28")
private Double totQ28; private Double totQ28;
@Column(name = "totQ29") @Column(name = "tot_tq_29")
private Double totQ29; private Double totQ29;
@Column(name = "totQ30") @Column(name = "tot_tq_30")
private Double totQ30; private Double totQ30;
@Column(name = "totQ31") @Column(name = "tot_tq_31")
private Double totQ31; private Double totQ31;
@Column(name = "totQ32") @Column(name = "tot_tq_32")
private Double totQ32; private Double totQ32;
@Column(name = "totQ33") @Column(name = "tot_tq_33")
private Double totQ33; private Double totQ33;
@Column(name = "totQ34") @Column(name = "tot_tq_34")
private Double totQ34; private Double totQ34;
@Column(name = "totQ35") @Column(name = "tot_tq_35")
private Double totQ35; private Double totQ35;
@Column(name = "totQ36") @Column(name = "tot_tq_36")
private Double totQ36; private Double totQ36;
@Column(name = "totQ37") @Column(name = "tot_tq_37")
private Double totQ37; private Double totQ37;
@Column(name = "totQ38") @Column(name = "tot_tq_38")
private Double totQ38; private Double totQ38;
@Column(name = "totQ39") @Column(name = "tot_tq_39")
private Double totQ39; private Double totQ39;
@Column(name = "totQ40") @Column(name = "tot_tq_40")
private Double totQ40; private Double totQ40;
@Column(name = "totQ41") @Column(name = "tot_tq_41")
private Double totQ41; private Double totQ41;
@Column(name = "totQ42") @Column(name = "tot_tq_42")
private Double totQ42; private Double totQ42;
@Column(name = "totQ43") @Column(name = "tot_tq_43")
private Double totQ43; private Double totQ43;
@Column(name = "totQ44") @Column(name = "tot_tq_44")
private Double totQ44; private Double totQ44;
@Column(name = "totQ45") @Column(name = "tot_tq_45")
private Double totQ45; private Double totQ45;
@Column(name = "totQ46") @Column(name = "tot_tq_46")
private Double totQ46; private Double totQ46;
@Column(name = "totQ47") @Column(name = "tot_tq_47")
private Double totQ47; private Double totQ47;
@Column(name = "totQ49") @Column(name = "tot_tq_49")
private Double totQ48; private Double totQ48;
@Column(name = "totQ49") @Column(name = "tot_tq_49")
private Double totQ49; private Double totQ49;
@Column(name = "totQ50") @Column(name = "tot_tq_50")
private Double totQ50; private Double totQ50;

View File

@@ -208,107 +208,107 @@ public class DataHarmpowerS {
private Double s50; private Double s50;
//在线监测添加的字段 //在线监测添加的字段
@Column(name = "totS") @Column(name = "tot_s")
private Double totS; private Double totS;
@Column(name = "totS1") @Column(name = "tot_ts_1")
private Double totS1; private Double totS1;
@Column(name = "totS2") @Column(name = "tot_ts_2")
private Double totS2; private Double totS2;
@Column(name = "totS3") @Column(name = "tot_ts_3")
private Double totS3; private Double totS3;
@Column(name = "totS4") @Column(name = "tot_ts_4")
private Double totS4; private Double totS4;
@Column(name = "totS5") @Column(name = "tot_ts_5")
private Double totS5; private Double totS5;
@Column(name = "totS6") @Column(name = "tot_ts_6")
private Double totS6; private Double totS6;
@Column(name = "totS7") @Column(name = "tot_ts_7")
private Double totS7; private Double totS7;
@Column(name = "totS8") @Column(name = "tot_ts_8")
private Double totS8; private Double totS8;
@Column(name = "totS9") @Column(name = "tot_ts_9")
private Double totS9; private Double totS9;
@Column(name = "totS10") @Column(name = "tot_ts_10")
private Double totS10; private Double totS10;
@Column(name = "totS11") @Column(name = "tot_ts_11")
private Double totS11; private Double totS11;
@Column(name = "totS12") @Column(name = "tot_ts_12")
private Double totS12; private Double totS12;
@Column(name = "totS13") @Column(name = "tot_ts_13")
private Double totS13; private Double totS13;
@Column(name = "totS14") @Column(name = "tot_ts_14")
private Double totS14; private Double totS14;
@Column(name = "totS15") @Column(name = "tot_ts_15")
private Double totS15; private Double totS15;
@Column(name = "totS16") @Column(name = "tot_ts_16")
private Double totS16; private Double totS16;
@Column(name = "totS17") @Column(name = "tot_ts_17")
private Double totS17; private Double totS17;
@Column(name = "totS18") @Column(name = "tot_ts_18")
private Double totS18; private Double totS18;
@Column(name = "totS19") @Column(name = "tot_ts_19")
private Double totS19; private Double totS19;
@Column(name = "totS20") @Column(name = "tot_ts_20")
private Double totS20; private Double totS20;
@Column(name = "totS21") @Column(name = "tot_ts_21")
private Double totS21; private Double totS21;
@Column(name = "totS22") @Column(name = "tot_ts_22")
private Double totS22; private Double totS22;
@Column(name = "totS23") @Column(name = "tot_ts_23")
private Double totS23; private Double totS23;
@Column(name = "totS24") @Column(name = "tot_ts_24")
private Double totS24; private Double totS24;
@Column(name = "totS25") @Column(name = "tot_ts_25")
private Double totS25; private Double totS25;
@Column(name = "totS26") @Column(name = "tot_ts_26")
private Double totS26; private Double totS26;
@Column(name = "totS27") @Column(name = "tot_ts_27")
private Double totS27; private Double totS27;
@Column(name = "totS28") @Column(name = "tot_ts_28")
private Double totS28; private Double totS28;
@Column(name = "totS29") @Column(name = "tot_ts_29")
private Double totS29; private Double totS29;
@Column(name = "totS30") @Column(name = "tot_ts_30")
private Double totS30; private Double totS30;
@Column(name = "totS31") @Column(name = "tot_ts_31")
private Double totS31; private Double totS31;
@Column(name = "totS32") @Column(name = "tot_ts_32")
private Double totS32; private Double totS32;
@Column(name = "totS33") @Column(name = "tot_ts_33")
private Double totS33; private Double totS33;
@Column(name = "totS34") @Column(name = "tot_ts_34")
private Double totS34; private Double totS34;
@Column(name = "totS35") @Column(name = "tot_ts_35")
private Double totS35; private Double totS35;
@Column(name = "totS36") @Column(name = "tot_ts_36")
private Double totS36; private Double totS36;
@Column(name = "totS37") @Column(name = "tot_ts_37")
private Double totS37; private Double totS37;
@Column(name = "totS38") @Column(name = "tot_ts_38")
private Double totS38; private Double totS38;
@Column(name = "totS39") @Column(name = "tot_ts_39")
private Double totS39; private Double totS39;
@Column(name = "totS40") @Column(name = "tot_ts_40")
private Double totS40; private Double totS40;
@Column(name = "totS41") @Column(name = "tot_ts_41")
private Double totS41; private Double totS41;
@Column(name = "totS42") @Column(name = "tot_ts_42")
private Double totS42; private Double totS42;
@Column(name = "totS43") @Column(name = "tot_ts_43")
private Double totS43; private Double totS43;
@Column(name = "totS44") @Column(name = "tot_ts_44")
private Double totS44; private Double totS44;
@Column(name = "totS45") @Column(name = "tot_ts_45")
private Double totS45; private Double totS45;
@Column(name = "totS46") @Column(name = "tot_ts_46")
private Double totS46; private Double totS46;
@Column(name = "totS47") @Column(name = "tot_ts_47")
private Double totS47; private Double totS47;
@Column(name = "totS49") @Column(name = "tot_ts_49")
private Double totS48; private Double totS48;
@Column(name = "totS49") @Column(name = "tot_ts_49")
private Double totS49; private Double totS49;
@Column(name = "totS50") @Column(name = "tot_ts_50")
private Double totS50; private Double totS50;

View File

@@ -17,6 +17,7 @@ public class PqsCommunicateDto {
private String description; private String description;
//1是在线 0是离线
private Integer type; private Integer type;
//是否更新updateTime标志数据上送更新1状态翻转不更新0 //是否更新updateTime标志数据上送更新1状态翻转不更新0
private Integer flag=0; private Integer flag=0;

View File

@@ -28,6 +28,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoField;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -85,8 +87,11 @@ public class LnDataDealController extends BaseController {
String value = messageDataDTO.getValue(); String value = messageDataDTO.getValue();
if(Objects.equals(DataTypeEnum.HARMONIC.getCode(),dataType)) { if(Objects.equals(DataTypeEnum.HARMONIC.getCode(),dataType)) {
MessageHarmonicDataSet messageHarmonicDataSet = JSONObject.parseObject(value, MessageHarmonicDataSet.class); MessageHarmonicDataSet messageHarmonicDataSet = JSONObject.parseObject(value, MessageHarmonicDataSet.class);
LocalDateTime localDateTime = messageHarmonicDataSet.getTIME(); LocalDateTime localDateTime = LocalDateTime.ofInstant(messageHarmonicDataSet.getTIME(), ZoneId.systemDefault());;
//排除上电下电等情况前置上送上不是整分的数据
if((localDateTime.getSecond() != 0)||localDateTime.get(ChronoField.MILLI_OF_SECOND)!=0){
System.out.println(111111111);
}
Integer flag = messageHarmonicDataSet.getFLAG(); Integer flag = messageHarmonicDataSet.getFLAG();
MessageP pq = messageHarmonicDataSet.getPQ(); MessageP pq = messageHarmonicDataSet.getPQ();
MessageV v = messageHarmonicDataSet.getV(); MessageV v = messageHarmonicDataSet.getV();

View File

@@ -192,6 +192,7 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
List<DataHarmpowerP> result = new ArrayList<>(); List<DataHarmpowerP> result = new ArrayList<>();
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerP.class);
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, InfluxDbSqlConstant.P, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.P, InfluxDbSqlConstant.P, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.samePrefixAndSuffix("tot_tp_", "tot_tp_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.regular(DataHarmpowerP::getLineId, lineList) influxQueryWrapper.regular(DataHarmpowerP::getLineId, lineList)
.select(DataHarmpowerP::getLineId) .select(DataHarmpowerP::getLineId)
.select(DataHarmpowerP::getPhasicType) .select(DataHarmpowerP::getPhasicType)
@@ -199,6 +200,9 @@ public class InfluxdbDataHarmpowerPImpl extends MppServiceImpl<RStatDataHarmPowe
.select(DataHarmpowerP::getP) .select(DataHarmpowerP::getP)
.select(DataHarmpowerP::getDf) .select(DataHarmpowerP::getDf)
.select(DataHarmpowerP::getPf) .select(DataHarmpowerP::getPf)
.select(DataHarmpowerP::getTotP)
.select(DataHarmpowerP::getTotDf)
.select(DataHarmpowerP::getTotPf)
.select(DataHarmpowerP::getQualityFlag) .select(DataHarmpowerP::getQualityFlag)
.select(DataHarmpowerP::getAbnormalFlag) .select(DataHarmpowerP::getAbnormalFlag)
.between(DataHarmpowerP::getTime, startTime, endTime) .between(DataHarmpowerP::getTime, startTime, endTime)

View File

@@ -187,11 +187,13 @@ public class InfluxdbDataHarmpowerQImpl extends MppServiceImpl<RStatDataHarmPowe
List<DataHarmpowerQ> result = new ArrayList<>(); List<DataHarmpowerQ> result = new ArrayList<>();
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerQ.class);
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, InfluxDbSqlConstant.Q, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.Q, InfluxDbSqlConstant.Q, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.samePrefixAndSuffix("tot_tq_", "tot_tq_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.regular(DataHarmpowerQ::getLineId, lineList) influxQueryWrapper.regular(DataHarmpowerQ::getLineId, lineList)
.select(DataHarmpowerQ::getLineId) .select(DataHarmpowerQ::getLineId)
.select(DataHarmpowerQ::getPhasicType) .select(DataHarmpowerQ::getPhasicType)
.select(DataHarmpowerQ::getValueType) .select(DataHarmpowerQ::getValueType)
.select(DataHarmpowerQ::getQ) .select(DataHarmpowerQ::getQ)
.select(DataHarmpowerQ::getTotQ)
.select(DataHarmpowerQ::getQualityFlag) .select(DataHarmpowerQ::getQualityFlag)
.select(DataHarmpowerQ::getAbnormalFlag) .select(DataHarmpowerQ::getAbnormalFlag)
.between(DataHarmpowerQ::getTime, startTime, endTime) .between(DataHarmpowerQ::getTime, startTime, endTime)

View File

@@ -187,11 +187,13 @@ public class InfluxdbDataHarmpowerSImpl extends MppServiceImpl<RStatDataHarmPowe
List<DataHarmpowerS> result = new ArrayList<>(); List<DataHarmpowerS> result = new ArrayList<>();
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class); InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(DataHarmpowerS.class);
influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, InfluxDbSqlConstant.S, HarmonicTimesUtil.harmonicTimesList(1, 50, 1)); influxQueryWrapper.samePrefixAndSuffix(InfluxDbSqlConstant.S, InfluxDbSqlConstant.S, HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.samePrefixAndSuffix("tot_ts_", "tot_ts_", HarmonicTimesUtil.harmonicTimesList(1, 50, 1));
influxQueryWrapper.regular(DataHarmpowerS::getLineId, lineList) influxQueryWrapper.regular(DataHarmpowerS::getLineId, lineList)
.select(DataHarmpowerS::getLineId) .select(DataHarmpowerS::getLineId)
.select(DataHarmpowerS::getPhasicType) .select(DataHarmpowerS::getPhasicType)
.select(DataHarmpowerS::getValueType) .select(DataHarmpowerS::getValueType)
.select(DataHarmpowerS::getS) .select(DataHarmpowerS::getS)
.select(DataHarmpowerS::getTotS)
.select(DataHarmpowerS::getQualityFlag) .select(DataHarmpowerS::getQualityFlag)
.select(DataHarmpowerS::getAbnormalFlag) .select(DataHarmpowerS::getAbnormalFlag)
.between(DataHarmpowerS::getTime, startTime, endTime) .between(DataHarmpowerS::getTime, startTime, endTime)

View File

@@ -31,6 +31,8 @@ public class DeviceRebootMessage {
private String ip; private String ip;
//终端型号 //终端型号
private String devType; private String devType;
//前置类型
private String comType;
//挂载单位 //挂载单位
private String org_name; private String org_name;
//组织名称 //组织名称

View File

@@ -100,12 +100,34 @@
<artifactId>spring-boot-starter-websocket</artifactId> <artifactId>spring-boot-starter-websocket</artifactId>
<version>2.7.12</version> <version>2.7.12</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>mq-spring-boot-starter</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.7.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>messageboot</finalName> <finalName>messageboot</finalName>
<plugins> <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>

View File

@@ -33,7 +33,7 @@ import java.util.Objects;
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "Device_Run_Flag_Topic", topic = "Device_Run_Flag_Topic",
consumerGroup = "Device_Run_Flag_Consumer", consumerGroup = "Device_Run_Flag_Consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -39,10 +39,12 @@ import java.util.concurrent.TimeUnit;
* @createTime 2023/8/11 15:32 * @createTime 2023/8/11 15:32
*/ */
@Component @Component
@org.springframework.boot.autoconfigure.condition.ConditionalOnProperty(
name = "mq.type", havingValue = "rocketmq", matchIfMissing = true)
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "LN_Topic", topic = "LN_Topic",
consumerGroup = "ln_consumer", consumerGroup = "ln_consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -33,7 +33,7 @@ import java.util.Objects;
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "Heart_Beat_Topic", topic = "Heart_Beat_Topic",
consumerGroup = "Heartb_Beat_Topic_Consumer", consumerGroup = "Heartb_Beat_Topic_Consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -31,7 +31,7 @@ import java.util.Objects;
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "Real_Time_Data_Topic", topic = "Real_Time_Data_Topic",
consumerGroup = "real_time_consumer", consumerGroup = "real_time_consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -33,7 +33,7 @@ import java.util.Objects;
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "log_Topic", topic = "log_Topic",
consumerGroup = "Log_Topic_Consumer", consumerGroup = "Log_Topic_Consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -32,7 +32,7 @@ import java.util.Objects;
@RocketMQMessageListener( @RocketMQMessageListener(
topic = "Topic_Reply_Topic", topic = "Topic_Reply_Topic",
consumerGroup = "Topic_Reply_Topic_Consumer", consumerGroup = "Topic_Reply_Topic_Consumer",
selectorExpression = "Test_Tag||Test_Keys", selectorExpression = "*",
consumeThreadNumber = 10, consumeThreadNumber = 10,
enableMsgTrace = true enableMsgTrace = true
) )

View File

@@ -0,0 +1,23 @@
package com.njcn.message.mq;
import com.njcn.message.messagedto.MessageDataDTO;
import com.njcn.mq.annotation.MqListener;
import com.njcn.stat.api.MessAnalysisFeignClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Collections;
@Component
@ConditionalOnProperty(name = "mq.type", havingValue = "redis-stream")
public class FrontDataMqListener {
@Resource
private MessAnalysisFeignClient messAnalysisFeignClient;
@MqListener(topic = "LN_Topic", group = "ln_consumer")
public void onFrontData(MessageDataDTO msg) {
messAnalysisFeignClient.analysis(Collections.singletonList(msg));
}
}

View File

@@ -0,0 +1,19 @@
package com.njcn.message.mq;
import com.njcn.message.constant.BusinessTopic;
import com.njcn.message.message.RecallMessage;
import com.njcn.mq.core.MqTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class RecallMqSender {
@Resource
private MqTemplate mqTemplate;
public void send(RecallMessage message, String nodeId) {
mqTemplate.send(nodeId + "_" + BusinessTopic.RECALL_TOPIC, message);
}
}

View File

@@ -1,8 +1,10 @@
package com.njcn.message.produce.template; package com.njcn.message.produce.template;
import com.alibaba.fastjson.JSON;
import com.njcn.message.constant.BusinessResource; import com.njcn.message.constant.BusinessResource;
import com.njcn.message.constant.BusinessTopic; import com.njcn.message.constant.BusinessTopic;
import com.njcn.message.message.AskRealDataMessage;
import com.njcn.middle.rocket.domain.BaseMessage; import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate; import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.client.producer.SendResult;
@@ -24,7 +26,8 @@ public class AskRealDataMessaggeTemplate extends RocketMQEnhanceTemplate {
public SendResult sendMember(BaseMessage askRealDataMessage,String nodeId) { public SendResult sendMember(BaseMessage askRealDataMessage,String nodeId) {
askRealDataMessage.setSource(BusinessResource.WEB_RESOURCE); askRealDataMessage.setSource(BusinessResource.WEB_RESOURCE);
askRealDataMessage.setKey("Test_Keys"); AskRealDataMessage dto = JSON.parseObject(askRealDataMessage.getMessageBody(), AskRealDataMessage.class);
return send(nodeId+"_"+BusinessTopic.ASK_REAL_DATA_TOPIC,"Test_Tag" , askRealDataMessage); askRealDataMessage.setKey(dto.getLine());
return send(BusinessTopic.ASK_REAL_DATA_TOPIC,nodeId , askRealDataMessage);
} }
} }

View File

@@ -1,7 +1,10 @@
package com.njcn.message.produce.template; package com.njcn.message.produce.template;
import com.alibaba.fastjson.JSON;
import com.njcn.message.constant.BusinessResource; import com.njcn.message.constant.BusinessResource;
import com.njcn.message.constant.BusinessTopic; import com.njcn.message.constant.BusinessTopic;
import com.njcn.message.message.AskRealDataMessage;
import com.njcn.message.message.DeviceRebootMessage;
import com.njcn.middle.rocket.domain.BaseMessage; import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate; import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.client.producer.SendResult;
@@ -24,7 +27,6 @@ public class DeviceRebootMessageTemplate extends RocketMQEnhanceTemplate {
public SendResult sendMember(BaseMessage baseMessage,String nodeId) { public SendResult sendMember(BaseMessage baseMessage,String nodeId) {
baseMessage.setSource(BusinessResource.WEB_RESOURCE); baseMessage.setSource(BusinessResource.WEB_RESOURCE);
baseMessage.setKey("Test_Keys"); return send(BusinessTopic.CONTROL_TOPIC,nodeId, baseMessage);
return send(nodeId+"_"+BusinessTopic.CONTROL_TOPIC,"Test_Tag", baseMessage);
} }
} }

View File

@@ -1,7 +1,10 @@
package com.njcn.message.produce.template; package com.njcn.message.produce.template;
import com.alibaba.fastjson.JSON;
import com.njcn.message.constant.BusinessResource; import com.njcn.message.constant.BusinessResource;
import com.njcn.message.constant.BusinessTopic; import com.njcn.message.constant.BusinessTopic;
import com.njcn.message.message.AskRealDataMessage;
import com.njcn.message.message.ProcessRebootMessage;
import com.njcn.middle.rocket.domain.BaseMessage; import com.njcn.middle.rocket.domain.BaseMessage;
import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate; import com.njcn.middle.rocket.template.RocketMQEnhanceTemplate;
import org.apache.rocketmq.client.producer.SendResult; import org.apache.rocketmq.client.producer.SendResult;
@@ -24,7 +27,8 @@ public class ProcessRebootMessageTemplate extends RocketMQEnhanceTemplate {
public SendResult sendMember(BaseMessage baseMessage,String nodeId) { public SendResult sendMember(BaseMessage baseMessage,String nodeId) {
baseMessage.setSource(BusinessResource.WEB_RESOURCE); baseMessage.setSource(BusinessResource.WEB_RESOURCE);
baseMessage.setKey("Test_Keys"); ProcessRebootMessage dto = JSON.parseObject(baseMessage.getMessageBody(), ProcessRebootMessage.class);
return send(nodeId+"_"+BusinessTopic.PROCESS_TOPIC,"Test_Tag", baseMessage); baseMessage.setKey(dto.getIndex()+"");
return send(BusinessTopic.PROCESS_TOPIC,nodeId, baseMessage);
} }
} }

View File

@@ -24,7 +24,6 @@ public class RecallMessaggeTemplate extends RocketMQEnhanceTemplate {
public SendResult sendMember(BaseMessage recallMessage,String nodeId) { public SendResult sendMember(BaseMessage recallMessage,String nodeId) {
recallMessage.setSource(BusinessResource.WEB_RESOURCE); recallMessage.setSource(BusinessResource.WEB_RESOURCE);
recallMessage.setKey("Test_Keys"); return send(BusinessTopic.RECALL_TOPIC,nodeId , recallMessage);
return send(nodeId+"_"+BusinessTopic.RECALL_TOPIC,"Test_Tag" , recallMessage);
} }
} }

View File

@@ -19,16 +19,13 @@ spring:
cloud: cloud:
nacos: nacos:
discovery: discovery:
ip: @service.server.url@
server-addr: @nacos.url@ server-addr: @nacos.url@
namespace: @nacos.namespace@ namespace: @nacos.namespace@
username: @nacos.username@
password: @nacos.password@
config: config:
server-addr: @nacos.url@
namespace: @nacos.namespace@
username: @nacos.username@ username: @nacos.username@
password: @nacos.password@ password: @nacos.password@
server-addr: @nacos.url@
namespace: @nacos.namespace@
file-extension: yaml file-extension: yaml
shared-configs: shared-configs:
- data-id: share-config.yaml - data-id: share-config.yaml

View File

@@ -0,0 +1,210 @@
package com.njcn.message.mq;
import com.alibaba.fastjson.JSON;
import com.njcn.message.message.RecallMessage;
import com.njcn.message.messagedto.MessageDataDTO;
import com.njcn.middle.stream.autoconfig.RedisStreamAutoConfiguration;
import com.njcn.mq.autoconfig.MqCoreAutoConfiguration;
import com.njcn.mq.container.MqListenerRegistry;
import com.njcn.mq.core.MqTemplate;
import com.njcn.mq.driver.redis.RedisStreamMqDriver;
import com.njcn.mq.driver.redis.RedisStreamMqDriverAutoConfiguration;
import com.njcn.mq.driver.rocketmq.RocketMqDriver;
import com.njcn.mq.driver.rocketmq.RocketMqDriverAutoConfiguration;
import com.njcn.mq.spi.MqDriver;
import com.njcn.stat.api.MessAnalysisFeignClient;
import org.apache.rocketmq.spring.autoconfigure.RocketMQProperties;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.data.redis.connection.stream.MapRecord;
import org.springframework.data.redis.connection.stream.ReadOffset;
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.connection.stream.StreamReadOptions;
import org.springframework.data.redis.connection.stream.StreamRecords;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
/**
* MQ starter 切片接入验证测试ApplicationContextRunner不启动全应用
* 真实 Redis 要求localhost:6379docker redis-stream-it仅上/下行收发用例需要,
* 纯装配用例不需要Lettuce 懒连接,不触发实际连接)。
*
* <p>装配一律用 {@code withConfiguration(AutoConfigurations.of(...))},让 Spring 按
* <b>真实 autoconfig 顺序</b>AutoConfigurationSorter处理与生产环境一致。以此
* 验证 {@link MqCoreAutoConfiguration} 的 {@code @ConditionalOnBean(MqDriver)} 能在
* 真实顺序下拿到 driver bean —— 这依赖 driver autoconfig 上的
* {@code @AutoConfigureBefore(MqCoreAutoConfiguration.class)}。若缺该保障,按类名字母序
* {@code com.njcn.mq.autoconfig.*} 先于 {@code com.njcn.mq.driver.*}core 会在 driver
* bean 注册前求值条件失败,导致 MqTemplate / MqListenerRegistry 不装配。
*/
public class MqSliceWiringTest {
private static boolean redisAvailable() {
try {
Socket s = new Socket();
s.connect(new InetSocketAddress("localhost", 6379), 500);
s.close();
return true;
} catch (Exception e) {
return false;
}
}
/** redis-stream 模式:真实 autoconfig 顺序装 5 个 autoconfig + 业务 bean上/下行用)。 */
private ApplicationContextRunner redisStreamRunner() {
return new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
RedisAutoConfiguration.class,
RedisStreamAutoConfiguration.class,
RedisStreamMqDriverAutoConfiguration.class,
RocketMqDriverAutoConfiguration.class,
MqCoreAutoConfiguration.class))
.withUserConfiguration(FrontDataMqListener.class, RecallMqSender.class)
.withBean(MessAnalysisFeignClient.class,
() -> mock(MessAnalysisFeignClient.class))
.withPropertyValues(
"mq.type=redis-stream",
"spring.redis.host=localhost",
"spring.redis.port=6379");
}
// ------------------------------------------------------------------
// 1. 装配mq.type 二选一 + core bean 在真实 autoconfig 顺序下装配
// ------------------------------------------------------------------
@Test
void testRedisStreamDriverSelected() {
// 纯装配检查,不依赖真实 RedisLettuce 懒连接)。
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
RedisAutoConfiguration.class,
RedisStreamAutoConfiguration.class,
RedisStreamMqDriverAutoConfiguration.class,
RocketMqDriverAutoConfiguration.class,
MqCoreAutoConfiguration.class))
.withPropertyValues(
"mq.type=redis-stream",
"spring.redis.host=localhost",
"spring.redis.port=6379")
.run(ctx -> {
assertThat(ctx).hasSingleBean(MqDriver.class);
assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RedisStreamMqDriver.class);
// 真实顺序下 core 的 @ConditionalOnBean(MqDriver) 必须命中
assertThat(ctx).hasSingleBean(MqTemplate.class);
assertThat(ctx).hasSingleBean(MqListenerRegistry.class);
});
}
@Test
void testRocketMqDriverSelected() {
// rocket 测试不依赖真实 Redis不装 RedisAutoConfigurationredis driver 因 mq.type 不匹配而 inactive。
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(
RedisStreamMqDriverAutoConfiguration.class,
RocketMqDriverAutoConfiguration.class,
MqCoreAutoConfiguration.class))
.withBean(RocketMQTemplate.class, () -> mock(RocketMQTemplate.class))
.withBean(RocketMQProperties.class, RocketMQProperties::new)
.withPropertyValues("mq.type=rocketmq")
.run(ctx -> {
assertThat(ctx).hasSingleBean(MqDriver.class);
assertThat(ctx.getBean(MqDriver.class)).isInstanceOf(RocketMqDriver.class);
assertThat(ctx).hasSingleBean(MqTemplate.class);
assertThat(ctx).hasSingleBean(MqListenerRegistry.class);
});
}
// ------------------------------------------------------------------
// 2. 上行(需要真实 Redis
// 向 LN_Topic stream XADD 一条消息,验证 FrontDataMqListener 触发了
// messAnalysisFeignClient.analysis(...)
// ------------------------------------------------------------------
@Test
void testUpstreamFrontData() {
Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping");
redisStreamRunner().run(ctx -> {
StringRedisTemplate redis = ctx.getBean(StringRedisTemplate.class);
MessAnalysisFeignClient mockClient = ctx.getBean(MessAnalysisFeignClient.class);
// 构造 RedisStreamMqDriver 消费时期望的字段格式
// enc=plain → body 即为原始 JSON参见 MessageCodec.encodeBody(json, false)
// stream key = StreamKeyBuilder.buildStream("LN_Topic") = "LN_Topic"
// (默认 envIsolation=false无 env 前缀)
MessageDataDTO dto = new MessageDataDTO();
dto.setDataType(1);
String json = JSON.toJSONString(dto);
Map<String, String> fields = new HashMap<String, String>();
fields.put("key", "test-key-upstream-1");
fields.put("tag", "");
fields.put("enc", "plain");
fields.put("body", json);
fields.put("ts", String.valueOf(System.currentTimeMillis()));
// XADD 到 LN_TopicMqListenerRegistry.start() 已在 context 启动时订阅该 stream
redis.opsForStream().add(
StreamRecords.newRecord().in("LN_Topic").ofMap(fields)
);
// 等待消费线程处理blockMs 默认 2000mstimeout=5000ms 足够)
verify(mockClient, timeout(5000)).analysis(anyList());
});
}
// ------------------------------------------------------------------
// 3. 下行(需要真实 Redis
// 通过 RecallMqSender 发送 RecallMessage验证 stream 内容正确
// ------------------------------------------------------------------
@Test
void testDownstreamRecall() {
Assumptions.assumeTrue(redisAvailable(), "Redis not available at localhost:6379, skipping");
redisStreamRunner().run(ctx -> {
StringRedisTemplate redis = ctx.getBean(StringRedisTemplate.class);
RecallMqSender sender = ctx.getBean(RecallMqSender.class);
// 清理,确保只有本次发送的消息
redis.delete("n1_recall_Topic");
RecallMessage msg = new RecallMessage();
msg.setGuid("g1");
// MqTemplate.send("n1_recall_Topic", msg) → RedisStreamMqDriver XADD
// stream key = StreamKeyBuilder.buildStream("n1_recall_Topic") = "n1_recall_Topic"
sender.send(msg, "n1");
Long size = redis.opsForStream().size("n1_recall_Topic");
assertThat(size).isGreaterThanOrEqualTo(1L);
@SuppressWarnings("unchecked")
List<MapRecord<String, Object, Object>> records =
redis.opsForStream().read(
StreamReadOptions.empty().count(1L),
StreamOffset.create("n1_recall_Topic", ReadOffset.from("0-0"))
);
assertThat(records).isNotEmpty();
Map<Object, Object> firstFields = records.get(0).getValue();
// DefaultMqTemplate.send(topic, payload) 使用 encodeBody(json, false) → enc="plain"
// 因此 body 即为原始 JSON无需 gzip 解压
String body = (String) firstFields.get("body");
RecallMessage result = JSON.parseObject(body, RecallMessage.class);
assertThat(result.getGuid()).isEqualTo("g1");
});
}
}