|
@@ -774,97 +774,102 @@ public class ScadaServiceImpl extends ServiceImpl<ScadaMapper, Scada> implements
|
|
|
DeviceArchiveManageVo vo = new DeviceArchiveManageVo();
|
|
|
BeanUtils.copyProperties(deviceArchiveManage, vo);
|
|
|
vo.setIsAlarm("0");
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(allocations)) {
|
|
|
-
|
|
|
- List<AllocationVo> allocationVos = new HashSet<>(allocations).stream().filter(allocation -> allocation.getDeviceId() != null &&
|
|
|
- allocation.getDeviceId().equals(vo.getId())).map(allocation -> {
|
|
|
- AllocationVo allocationVo = new AllocationVo();
|
|
|
- BeanUtils.copyProperties(allocation, allocationVo);
|
|
|
- Scada scadaBelong = null;
|
|
|
-
|
|
|
-
|
|
|
- if (!CollectionUtils.isEmpty(scadas)) {
|
|
|
- List<Scada> scadaList = scadas.stream()
|
|
|
- .filter(scada -> scada.getCode() != null && scada.getCode().equals(allocation.getVariableCode()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(scadaList)) {
|
|
|
- scadaBelong = scadaList.get(0);
|
|
|
- Long accuracy= allocation.getAccuracy();
|
|
|
-
|
|
|
- if(accuracy==null){
|
|
|
- accuracy=2L;
|
|
|
- }
|
|
|
-
|
|
|
- BigDecimal bd = new BigDecimal(scadaBelong.getValue());
|
|
|
- double roundedNumber = bd.setScale(Integer.parseInt(accuracy+""), BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
- NumberFormat nf = NumberFormat.getInstance();
|
|
|
- nf.setGroupingUsed(false);
|
|
|
-
|
|
|
- if(accuracy>0L){
|
|
|
- scadaBelong.setValue(nf.format(roundedNumber));
|
|
|
- }else{
|
|
|
- scadaBelong.setValue(nf.format((int)roundedNumber));
|
|
|
- }
|
|
|
-
|
|
|
- allocationVo.setScada(scadaBelong);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- Set<Long> reportIdSets = getReportIdSets(Collections.singletonList(allocation));
|
|
|
- if (!CollectionUtils.isEmpty(scadaReports) && !CollectionUtils.isEmpty(reportIdSets)) {
|
|
|
-
|
|
|
- List<ScadaReport> reportsList=new ArrayList<>();
|
|
|
- List<ScadaReport> reports = scadaReports.stream().filter(scadaReport -> scadaReport.getId() != null
|
|
|
- && reportIdSets.contains(scadaReport.getId())).collect(Collectors.toList());
|
|
|
-
|
|
|
- allocationVo.setIsAlarm("0");
|
|
|
-
|
|
|
- if (scadaBelong != null && scadaBelong.getValue() != null) {
|
|
|
- for (ScadaReport scadaReport : reports) {
|
|
|
- if (scadaReport.getReportLower() == null || scadaReport.getReportUpper() == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (!isNumber(scadaReport.getReportLower())
|
|
|
- || !isNumber(scadaReport.getReportUpper())
|
|
|
- || !isNumber(scadaBelong.getValue())) {
|
|
|
- continue;
|
|
|
+ try {
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(allocations)) {
|
|
|
+
|
|
|
+ List<AllocationVo> allocationVos = new HashSet<>(allocations).stream().filter(allocation -> allocation.getDeviceId() != null &&
|
|
|
+ allocation.getDeviceId().equals(vo.getId())).map(allocation -> {
|
|
|
+ AllocationVo allocationVo = new AllocationVo();
|
|
|
+ BeanUtils.copyProperties(allocation, allocationVo);
|
|
|
+ Scada scadaBelong = null;
|
|
|
+
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(scadas)) {
|
|
|
+ List<Scada> scadaList = scadas.stream()
|
|
|
+ .filter(scada -> scada.getCode() != null && scada.getCode().equals(allocation.getVariableCode()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(scadaList)) {
|
|
|
+ scadaBelong = scadaList.get(0);
|
|
|
+ Long accuracy = allocation.getAccuracy();
|
|
|
+
|
|
|
+ if (accuracy == null) {
|
|
|
+ accuracy = 2L;
|
|
|
}
|
|
|
- Double lower = Double.parseDouble(scadaReport.getReportLower());
|
|
|
- Double upper = Double.parseDouble(scadaReport.getReportUpper());
|
|
|
- Double value = Double.parseDouble(scadaBelong.getValue());
|
|
|
-
|
|
|
- if (value.compareTo(upper) <= 0 && value.compareTo(lower) >= 0) {
|
|
|
- allocationVo.setIsAlarm("1");
|
|
|
- vo.setIsAlarm("1");
|
|
|
- reportsList.add(scadaReport);
|
|
|
-
|
|
|
+
|
|
|
+ BigDecimal bd = new BigDecimal(scadaBelong.getValue());
|
|
|
+ double roundedNumber = bd.setScale(Integer.parseInt(accuracy + ""), BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ NumberFormat nf = NumberFormat.getInstance();
|
|
|
+ nf.setGroupingUsed(false);
|
|
|
+
|
|
|
+ if (accuracy > 0L) {
|
|
|
+ scadaBelong.setValue(nf.format(roundedNumber));
|
|
|
+ } else {
|
|
|
+ scadaBelong.setValue(nf.format((int) roundedNumber));
|
|
|
}
|
|
|
|
|
|
+ allocationVo.setScada(scadaBelong);
|
|
|
}
|
|
|
}
|
|
|
- allocationVo.setScadaReports(reportsList);
|
|
|
- }
|
|
|
- return allocationVo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Set<Long> reportIdSets = getReportIdSets(Collections.singletonList(allocation));
|
|
|
+ if (!CollectionUtils.isEmpty(scadaReports) && !CollectionUtils.isEmpty(reportIdSets)) {
|
|
|
+
|
|
|
+ List<ScadaReport> reportsList = new ArrayList<>();
|
|
|
+ List<ScadaReport> reports = scadaReports.stream().filter(scadaReport -> scadaReport.getId() != null
|
|
|
+ && reportIdSets.contains(scadaReport.getId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ allocationVo.setIsAlarm("0");
|
|
|
+
|
|
|
+ if (scadaBelong != null && scadaBelong.getValue() != null) {
|
|
|
+ for (ScadaReport scadaReport : reports) {
|
|
|
+ if (scadaReport.getReportLower() == null || scadaReport.getReportUpper() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!isNumber(scadaReport.getReportLower())
|
|
|
+ || !isNumber(scadaReport.getReportUpper())
|
|
|
+ || !isNumber(scadaBelong.getValue())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Double lower = Double.parseDouble(scadaReport.getReportLower());
|
|
|
+ Double upper = Double.parseDouble(scadaReport.getReportUpper());
|
|
|
+ Double value = Double.parseDouble(scadaBelong.getValue());
|
|
|
+
|
|
|
+ if (value.compareTo(upper) <= 0 && value.compareTo(lower) >= 0) {
|
|
|
+ allocationVo.setIsAlarm("1");
|
|
|
+ vo.setIsAlarm("1");
|
|
|
+ reportsList.add(scadaReport);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ }
|
|
|
+ allocationVo.setScadaReports(reportsList);
|
|
|
+ }
|
|
|
+ return allocationVo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
- allocationVos = allocationVos.stream().sorted(Comparator.comparing(AllocationVo::getSortNumber)).collect(Collectors.toList());
|
|
|
|
|
|
- vo.setAllocations(allocationVos);
|
|
|
- }
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(deviceQuery.getDeviceTypeIds())) {
|
|
|
- List<String> deviceTypeList = Arrays.stream(deviceQuery.getDeviceTypeIds().split(",")).map(String::trim)
|
|
|
- .collect(Collectors.toList());
|
|
|
- for (String s : deviceTypeList) {
|
|
|
- if (StringUtil.isNotEmpty(vo.getDeviceType()) && vo.getDeviceType().equals(s)) {
|
|
|
- return vo;
|
|
|
+ allocationVos = allocationVos.stream().sorted(Comparator.comparing(AllocationVo::getSortNumber)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ vo.setAllocations(allocationVos);
|
|
|
+ }
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(deviceQuery.getDeviceTypeIds())) {
|
|
|
+ List<String> deviceTypeList = Arrays.stream(deviceQuery.getDeviceTypeIds().split(",")).map(String::trim)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (String s : deviceTypeList) {
|
|
|
+ if (StringUtil.isNotEmpty(vo.getDeviceType()) && vo.getDeviceType().equals(s)) {
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
- return null;
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
}
|
|
|
return vo;
|
|
|
}).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+
|
|
|
return manageVos;
|
|
|
}
|
|
|
|