|
@@ -342,7 +342,11 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
if (CollUtil.isNotEmpty(indexAllocationList)) {
|
|
|
List<TfIndexAllocation> indexAllocationAll = indexAllocationService.list();
|
|
|
List<String> indexCodeList = indexAllocationAll.stream().map(TfIndexAllocation::getVariableCode).collect(Collectors.toList());
|
|
|
- indexAllocationList.forEach(info -> {
|
|
|
+ List<TfIndexAllocation> newIndexAllocationList = new ArrayList<>(indexAllocationList);
|
|
|
+ newIndexAllocationList = newIndexAllocationList.stream()
|
|
|
+ .sorted(Comparator.comparing(TfIndexAllocation::getCreateTime).reversed())
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TfIndexAllocation::getVariableCode))), ArrayList::new));
|
|
|
+ newIndexAllocationList.forEach(info -> {
|
|
|
if (!indexCodeList.contains(info.getVariableCode())) {
|
|
|
indexAllocationService.save(info);
|
|
|
} else {
|
|
@@ -354,13 +358,18 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
|
|
|
if (CollUtil.isNotEmpty(scadaDtuParModelList)) {
|
|
|
List<ScadaDtuParModel> scadaDtuParModelAll = scadaDtuParModelService.list();
|
|
|
- List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(ScadaDtuParModel::getDtuId).collect(Collectors.toList());
|
|
|
- scadaDtuParModelList.forEach(info -> {
|
|
|
- if (!scadaDtuParModelDtuIdList.contains(info.getDtuId())) {
|
|
|
+ List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(o -> o.getDtuId() + "-" + o.getFieldName()).collect(Collectors.toList());
|
|
|
+ List<ScadaDtuParModel> newScadaDtuParModelList = new ArrayList<>(scadaDtuParModelList);
|
|
|
+ newScadaDtuParModelList = newScadaDtuParModelList.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName()))), ArrayList::new));
|
|
|
+ newScadaDtuParModelList.forEach(info -> {
|
|
|
+ if (!scadaDtuParModelDtuIdList.contains(info.getDtuId() + "-" + info.getFieldName())) {
|
|
|
scadaDtuParModelService.save(info);
|
|
|
} else {
|
|
|
scadaDtuParModelService.update(info,
|
|
|
- new QueryWrapper<ScadaDtuParModel>().lambda().eq(ScadaDtuParModel::getDtuId, info.getDtuId()));
|
|
|
+ new QueryWrapper<ScadaDtuParModel>().lambda()
|
|
|
+ .eq(ScadaDtuParModel::getDtuId, info.getDtuId())
|
|
|
+ .eq(ScadaDtuParModel::getFieldName, info.getFieldName()));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -375,7 +384,7 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
scadaMapper.insertMouth(scadaHistoryList, tableName);
|
|
|
|
|
|
|
|
|
- List<Scada> list = scadaHistoryList;
|
|
|
+ List<Scada> list = new ArrayList<>(scadaHistoryList);
|
|
|
list = list.stream()
|
|
|
.sorted(Comparator.comparing(Scada::getScadaTime).reversed())
|
|
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Scada::getCode))), ArrayList::new));
|
|
@@ -812,7 +821,11 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
if (CollUtil.isNotEmpty(indexAllocationList)) {
|
|
|
List<TfIndexAllocation> indexAllocationAll = indexAllocationService.list();
|
|
|
List<String> indexCodeList = indexAllocationAll.stream().map(TfIndexAllocation::getVariableCode).collect(Collectors.toList());
|
|
|
- indexAllocationList.forEach(info -> {
|
|
|
+ List<TfIndexAllocation> newIndexAllocationList = new ArrayList<>(indexAllocationList);
|
|
|
+ newIndexAllocationList = newIndexAllocationList.stream()
|
|
|
+ .sorted(Comparator.comparing(TfIndexAllocation::getCreateTime).reversed())
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(TfIndexAllocation::getVariableCode))), ArrayList::new));
|
|
|
+ newIndexAllocationList.forEach(info -> {
|
|
|
if (!indexCodeList.contains(info.getVariableCode())) {
|
|
|
indexAllocationService.save(info);
|
|
|
} else {
|
|
@@ -824,13 +837,18 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
|
|
|
if (CollUtil.isNotEmpty(scadaDtuParModelList)) {
|
|
|
List<ScadaDtuParModel> scadaDtuParModelAll = scadaDtuParModelService.list();
|
|
|
- List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(ScadaDtuParModel::getDtuId).collect(Collectors.toList());
|
|
|
- scadaDtuParModelList.forEach(info -> {
|
|
|
- if (!scadaDtuParModelDtuIdList.contains(info.getDtuId())) {
|
|
|
+ List<String> scadaDtuParModelDtuIdList = scadaDtuParModelAll.stream().map(o -> o.getDtuId() + "-" + o.getFieldName()).collect(Collectors.toList());
|
|
|
+ List<ScadaDtuParModel> newScadaDtuParModelList = new ArrayList<>(scadaDtuParModelList);
|
|
|
+ newScadaDtuParModelList = newScadaDtuParModelList.stream()
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName()))), ArrayList::new));
|
|
|
+ newScadaDtuParModelList.forEach(info -> {
|
|
|
+ if (!scadaDtuParModelDtuIdList.contains(info.getDtuId() + "-" + info.getFieldName())) {
|
|
|
scadaDtuParModelService.save(info);
|
|
|
} else {
|
|
|
scadaDtuParModelService.update(info,
|
|
|
- new QueryWrapper<ScadaDtuParModel>().lambda().eq(ScadaDtuParModel::getDtuId, info.getDtuId()));
|
|
|
+ new QueryWrapper<ScadaDtuParModel>().lambda()
|
|
|
+ .eq(ScadaDtuParModel::getDtuId, info.getDtuId())
|
|
|
+ .eq(ScadaDtuParModel::getFieldName, info.getFieldName()));
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -845,7 +863,7 @@ public class MqttMessageHandler implements MessageHandler {
|
|
|
scadaMapper.insertMouth(scadaHistoryList, tableName);
|
|
|
|
|
|
|
|
|
- List<Scada> list = scadaHistoryList;
|
|
|
+ List<Scada> list = new ArrayList<>(scadaHistoryList);
|
|
|
list = list.stream()
|
|
|
.sorted(Comparator.comparing(Scada::getScadaTime).reversed())
|
|
|
.collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(Scada::getCode))), ArrayList::new));
|