|
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.tofly.common.core.util.DateUtil;
|
|
|
import com.tofly.zmrqScada.dto.ScadaDtuDataVo;
|
|
|
import com.tofly.zmrqScada.dto.ScadaDtuListVo;
|
|
|
import com.tofly.zmrqScada.entity.ScadaDtu;
|
|
@@ -245,12 +246,21 @@ public class IScadaDtuSyncImpl implements ScadaDtuSyncService {
|
|
|
i.setDtuId(dtuId);
|
|
|
});
|
|
|
});
|
|
|
- List<ScadaDyuData> list = new ArrayList<>();
|
|
|
+ List<ScadaDyuData> originalList = new ArrayList<>();
|
|
|
|
|
|
- data.forEach(info->{
|
|
|
- list.addAll(info.getFieldValueList());
|
|
|
- });
|
|
|
- scadaDyuDataService.saveBatch(list);
|
|
|
+ data.forEach(info-> originalList.addAll(info.getFieldValueList()));
|
|
|
+ List<ScadaDyuData> list = originalList.stream()
|
|
|
+ .sorted(Comparator.comparing(ScadaDyuData::getCollectTime).reversed())
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
|
|
+ new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName() + "-" + DateUtil.getDateFormat(o.getCollectTime(), "yyyyMMddHHmm")))), ArrayList::new));
|
|
|
+ for (ScadaDyuData scadaDyuData : list) {
|
|
|
+ try {
|
|
|
+ scadaDyuDataService.save(scadaDyuData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("重复数据不作插入");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -318,11 +328,21 @@ public class IScadaDtuSyncImpl implements ScadaDtuSyncService {
|
|
|
i.setDtuId(dtuId);
|
|
|
});
|
|
|
});
|
|
|
- List<ScadaDyuData> list = new ArrayList<>();
|
|
|
- data.forEach(info->{
|
|
|
- list.addAll(info.getFieldValueList());
|
|
|
- });
|
|
|
- scadaDyuDataService.saveBatch(list);
|
|
|
+ List<ScadaDyuData> originalList = new ArrayList<>();
|
|
|
+
|
|
|
+ data.forEach(info-> originalList.addAll(info.getFieldValueList()));
|
|
|
+ List<ScadaDyuData> list = originalList.stream()
|
|
|
+ .sorted(Comparator.comparing(ScadaDyuData::getCollectTime).reversed())
|
|
|
+ .collect(Collectors.collectingAndThen(Collectors.toCollection(() ->
|
|
|
+ new TreeSet<>(Comparator.comparing(o -> o.getDtuId() + "-" + o.getFieldName() + "-" + DateUtil.getDateFormat(o.getCollectTime(), "yyyyMMddHHmm")))), ArrayList::new));
|
|
|
+ for (ScadaDyuData scadaDyuData : list) {
|
|
|
+ try {
|
|
|
+ scadaDyuDataService.save(scadaDyuData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log.info("重复数据不作插入");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|