|
|
@@ -19,8 +19,10 @@ import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.slope.detection.dao.mysql.*;
|
|
|
+import com.sckw.slope.detection.dao.tdengine.InsTablesMapper;
|
|
|
import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
|
|
|
import com.sckw.slope.detection.model.dos.mysql.*;
|
|
|
+import com.sckw.slope.detection.model.dos.tdengine.InsTables;
|
|
|
import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
|
|
|
import com.sckw.slope.detection.model.dto.*;
|
|
|
import com.sckw.slope.detection.model.param.DeviceQuery;
|
|
|
@@ -38,9 +40,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.time.ZoneOffset;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -76,6 +77,9 @@ public class ProjectService {
|
|
|
@Autowired
|
|
|
SlopeDataMapper slopeDataMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ InsTablesMapper insTablesMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsProjectDeviceMapper projectDeviceMapper;
|
|
|
|
|
|
@@ -440,6 +444,7 @@ public class ProjectService {
|
|
|
//集成要素-测量值计算
|
|
|
integrationItem(headerData, deviceId, kwsDevice, returnList, type);
|
|
|
}
|
|
|
+ returnList = returnList.stream().distinct().collect(Collectors.toList());
|
|
|
return HttpResult.ok(returnList);
|
|
|
} else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
|
|
|
String deviceId = param.getDeviceId();
|
|
|
@@ -491,7 +496,7 @@ public class ProjectService {
|
|
|
if (!CollectionUtils.isEmpty(longList)) {
|
|
|
List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
|
|
|
.in(KwsIntegration::getId, longList)
|
|
|
- .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type), KwsIntegration::getIntegrationName, type));
|
|
|
if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
|
|
|
kwsIntegrations.forEach(integration -> {
|
|
|
Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
@@ -576,22 +581,27 @@ public class ProjectService {
|
|
|
for (int i = 0; i < selected.size(); i++) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
SlopeData currSlopeData = selected.get(i);
|
|
|
- String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+// String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
|
|
|
+ String key = simpleDateFormat.format(currSlopeData.getTs());
|
|
|
SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
- LocalDateTime localDateTime = currSlopeData.getTs();
|
|
|
+ Date localDateTime = currSlopeData.getTs();
|
|
|
long epochMilli1 = 0L;
|
|
|
String val2 = "0";
|
|
|
- LocalDateTime localDateTime1 = lastSlopeData.getTs();
|
|
|
+ Date localDateTime1 = lastSlopeData.getTs();
|
|
|
if (lastSlopeData != null) {
|
|
|
- epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+// epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ epochMilli1 = localDateTime1.getTime();
|
|
|
val2 = lastSlopeData.getVal();
|
|
|
}
|
|
|
- long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
- epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+// long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ long epochMilli = localDateTime.getTime();
|
|
|
+// epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ epochMilli1 = localDateTime1.getTime();
|
|
|
String val1 = currSlopeData.getVal();
|
|
|
long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
- decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
|
|
|
+ decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
map.put(key, decimal);
|
|
|
mapList.add(map);
|
|
|
}
|
|
|
@@ -692,8 +702,10 @@ public class ProjectService {
|
|
|
for (SlopeData message : selected) {
|
|
|
BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
- LocalDateTime createTime = message.getCreateTime();
|
|
|
- String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ Date createTime = message.getTs();
|
|
|
+// String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
+ String key = simpleDateFormat.format(createTime);
|
|
|
String line = message.getLine();
|
|
|
String val1 = message.getVal();
|
|
|
if (itemList.contains(partName)) {
|
|
|
@@ -702,7 +714,7 @@ public class ProjectService {
|
|
|
double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
|
double cosValue = Math.cos(angleInRadians);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
|
|
|
- double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
+ double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
}
|
|
|
}
|
|
|
@@ -720,7 +732,7 @@ public class ProjectService {
|
|
|
if (itemList.contains(partName)) {
|
|
|
if (Objects.nonNull(currentValue)) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
- offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -753,7 +765,7 @@ public class ProjectService {
|
|
|
if (!CollectionUtils.isEmpty(longList)) {
|
|
|
List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>()
|
|
|
.in(KwsIntegration::getId, longList)
|
|
|
- .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type),KwsIntegration::getIntegrationName,type));
|
|
|
+ .eq(org.apache.commons.lang3.StringUtils.isNotBlank(type), KwsIntegration::getIntegrationName, type));
|
|
|
if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
|
|
|
kwsIntegrations.forEach(integration -> {
|
|
|
Map<String, ProjectCatLogVO> returnMap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
@@ -832,36 +844,59 @@ public class ProjectService {
|
|
|
Date date = new Date();
|
|
|
String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
+ String snCode = kwsDevice.getSnCode();
|
|
|
+ InsTables insTables = insTablesMapper.selectTableIsExit("slope_data_" + snCode);
|
|
|
+ if (insTables == null) {
|
|
|
+ insTablesMapper.createTable("slope_data_" + snCode);
|
|
|
+ }
|
|
|
List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), item, dateStart, dateEnd);
|
|
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(selected)) {
|
|
|
for (int i = 0; i < selected.size(); i++) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
SlopeData currSlopeData = selected.get(i);
|
|
|
- String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
- SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
- LocalDateTime localDateTime = currSlopeData.getTs();
|
|
|
- long epochMilli1 = 0L;
|
|
|
- String val2 = "0";
|
|
|
- LocalDateTime localDateTime1 = lastSlopeData.getTs();
|
|
|
- if (lastSlopeData != null) {
|
|
|
- epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
- val2 = lastSlopeData.getVal();
|
|
|
+// String key = currSlopeData.getTs().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM-dd HH:mm:ss");
|
|
|
+ String key = simpleDateFormat.format(currSlopeData.getTs());
|
|
|
+ if (i == selected.size() - 1) {
|
|
|
+// Date localDateTime = currSlopeData.getTs();
|
|
|
+// long epochMilli1 = 0L;
|
|
|
+// String val2 = "0";
|
|
|
+// long epochMilli = localDateTime.getTime();
|
|
|
+// String val1 = currSlopeData.getVal();
|
|
|
+// long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
+// long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
+// decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
+ map.put(key, decimal);
|
|
|
+ mapList.add(map);
|
|
|
+ } else {
|
|
|
+ SlopeData lastSlopeData = selected.get(i + 1);
|
|
|
+ Date localDateTime = currSlopeData.getTs();
|
|
|
+ long epochMilli1 = 0L;
|
|
|
+ String val2 = "0";
|
|
|
+ Date localDateTime1 = lastSlopeData.getTs();
|
|
|
+ if (lastSlopeData != null) {
|
|
|
+// epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ epochMilli1 = localDateTime1.getTime();
|
|
|
+ val2 = lastSlopeData.getVal();
|
|
|
+ }
|
|
|
+// long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ long epochMilli = localDateTime.getTime();
|
|
|
+// epochMilli1= localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
+ epochMilli1 = localDateTime1.getTime();
|
|
|
+ String val1 = currSlopeData.getVal();
|
|
|
+ long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
+ long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
+ decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
+ map.put(key, decimal);
|
|
|
+ mapList.add(map);
|
|
|
}
|
|
|
- long epochMilli = localDateTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
- epochMilli1 = localDateTime1.toInstant(ZoneOffset.of("+8")).toEpochMilli();
|
|
|
- String val1 = currSlopeData.getVal();
|
|
|
- long t = (epochMilli - epochMilli1) / (60 * 60 * 1000);
|
|
|
- long val = Long.parseLong(val1) - Long.parseLong(val2);
|
|
|
- decimal = BigDecimal.valueOf(val).divide((new BigDecimal(t).multiply(new BigDecimal(t))));
|
|
|
- map.put(key, decimal);
|
|
|
- mapList.add(map);
|
|
|
}
|
|
|
+ projectCatLogVO.setType(integrationName);
|
|
|
+ projectCatLogVO.setMonitor(mapList);
|
|
|
+ returnMap.put(integrationName, projectCatLogVO);
|
|
|
+ returnList.add(returnMap);
|
|
|
}
|
|
|
- projectCatLogVO.setType(integrationName);
|
|
|
- projectCatLogVO.setMonitor(mapList);
|
|
|
- returnMap.put(integrationName, projectCatLogVO);
|
|
|
- returnList.add(returnMap);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -960,18 +995,23 @@ public class ProjectService {
|
|
|
for (SlopeData message : selected) {
|
|
|
BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
Map<String, Object> datemap = new HashMap<>(NumberConstant.SIXTEEN);
|
|
|
- LocalDateTime createTime = message.getCreateTime();
|
|
|
- String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ Date createTime = message.getTs();
|
|
|
+// String key = createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH");
|
|
|
+ String key = format.format(createTime);
|
|
|
String line = message.getLine();
|
|
|
String val1 = message.getVal();
|
|
|
if (itemList.contains(partName)) {
|
|
|
if (Objects.nonNull(currentValue)) {
|
|
|
SlopeData selectListByLine = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), "2");
|
|
|
- double angleInRadians = Math.toRadians(selected == null ? 0L : Double.parseDouble(selectListByLine.getVal()));
|
|
|
+ double angleInRadians = Math.toRadians(selected == null ? 0L : (selectListByLine == null ? 0L : Double.parseDouble(selectListByLine.getVal())));
|
|
|
double cosValue = Math.cos(angleInRadians);
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(val1)) {
|
|
|
- double doubleValue = (new BigDecimal(val1).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
- offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
+ BigDecimal subtract = new BigDecimal(val1).subtract(currentValue);
|
|
|
+ if (subtract.compareTo(new BigDecimal("0.00")) != 0) {
|
|
|
+ double doubleValue = subtract.divide(new BigDecimal("360"), 9, BigDecimal.ROUND_HALF_UP).doubleValue();
|
|
|
+ offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -988,7 +1028,7 @@ public class ProjectService {
|
|
|
if (itemList.contains(partName)) {
|
|
|
if (Objects.nonNull(currentValue)) {
|
|
|
if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
- offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000), 9, BigDecimal.ROUND_HALF_UP);
|
|
|
}
|
|
|
}
|
|
|
}
|