|
|
@@ -8,7 +8,6 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.NumberConstant;
|
|
|
import com.sckw.core.model.enums.DeviceEnum;
|
|
|
-import com.sckw.core.model.enums.DictEnum;
|
|
|
import com.sckw.core.model.enums.DictItemEnum;
|
|
|
import com.sckw.core.model.page.PageRes;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
@@ -39,6 +38,8 @@ import org.springframework.util.CollectionUtils;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneOffset;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -65,6 +66,9 @@ public class ProjectService {
|
|
|
@Autowired
|
|
|
KwsDeviceIntegrationMapper deviceIntegrationMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ KwsIntegrationMapper integrationMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsDeviceMapper deviceMapper;
|
|
|
|
|
|
@@ -77,6 +81,9 @@ public class ProjectService {
|
|
|
@Autowired
|
|
|
KwsDeviceReferenceMapper deviceReferenceMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ KwsThresholdMapper thresholdMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
KwsMountainCompanyMapper mountainCompanyMapper;
|
|
|
|
|
|
@@ -365,10 +372,6 @@ public class ProjectService {
|
|
|
String latitude = param.getLatitude();
|
|
|
String projectId = param.getProjectId();
|
|
|
if (String.valueOf(NumberConstant.FOUR).equals(latitude)) {
|
|
|
- Map<String, SystemDict> dictList = commonService.getDictList(null, new HashMap<String, String>() {{
|
|
|
- put("code", DictEnum.MODEL_PART.getCodeType());
|
|
|
- put("type", "1");
|
|
|
- }});
|
|
|
String deviceId = param.getDeviceId();
|
|
|
String mountainId = headerData.getMountainId();
|
|
|
KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
@@ -379,93 +382,32 @@ public class ProjectService {
|
|
|
if (kwsDevice == null) {
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
- //集成要素
|
|
|
- List<DeviceElementDTO> integratedElementList = deviceIntegrationMapper.selectIntegratedElement(projectId,
|
|
|
- mountainId, null, Long.parseLong(deviceId));
|
|
|
- //集成要素
|
|
|
- List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
- .eq(KwsDeviceIntegration::getMountainId, mountainId)
|
|
|
- .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
- );
|
|
|
-
|
|
|
//当前设备下的所有基本要素
|
|
|
- List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
|
|
|
- if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
- for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
- String partName = projectDeviceVO.getPartName();
|
|
|
- //设置过阈值的基本要素
|
|
|
- List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
- .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
- .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
- .eq(KwsDeviceReference::getType, 1)
|
|
|
- .eq(KwsDeviceReference::getItem, partName)
|
|
|
- .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
- );
|
|
|
- KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
- if (!CollectionUtils.isEmpty(references)) {
|
|
|
- deviceReference = references.get(0);
|
|
|
- }
|
|
|
- SlopeData slopeData = slopeDataMapper.selectListByLine(kwsDevice.getSnCode(), partName);
|
|
|
- String val = slopeData == null ? null : slopeData.getVal();
|
|
|
- //基准值
|
|
|
- BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
- BigDecimal offsetValue = new BigDecimal("0.00");
|
|
|
- if (currentValue != null) {
|
|
|
- /**存在经纬度海拔值的需要公式计算*/
|
|
|
- List<String> itemList = new ArrayList<>();
|
|
|
- itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
- Date date = new Date();
|
|
|
- String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
- String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
- List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
- if (!CollectionUtils.isEmpty(selected)){
|
|
|
- for (SlopeData message : selected) {
|
|
|
- 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 cosValue = Math.cos(angleInRadians);
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
- double doubleValue = (new BigDecimal(val).subtract(currentValue)).divide(new BigDecimal(360)).doubleValue();
|
|
|
- offsetValue = new BigDecimal(equatorial_circumference).multiply(new BigDecimal(cosValue)).multiply(new BigDecimal(doubleValue));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
- if (itemList.contains(partName)) {
|
|
|
- if (Objects.nonNull(currentValue)) {
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
- offsetValue = new BigDecimal(val).subtract(currentValue);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- itemList.clear();
|
|
|
- itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
- if (itemList.contains(partName)) {
|
|
|
- if (Objects.nonNull(currentValue)) {
|
|
|
- if (org.apache.commons.lang3.StringUtils.isNotBlank(val)) {
|
|
|
- offsetValue = new BigDecimal(val).divide(new BigDecimal(1000));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ List<ProjectCatLogVO> returnList = new ArrayList<>();
|
|
|
+ basicItem(mountainId, projectId, deviceId, kwsDevice, returnList);
|
|
|
|
|
|
+ //集成要素 折线图
|
|
|
+ //集成要素-测量值计算
|
|
|
+ integrationItem(headerData, deviceId, kwsDevice, returnList);
|
|
|
LocalDateTime localDateTime = DateUtil.localDateToLocalDateTimeStart(LocalDate.now());
|
|
|
+ return HttpResult.ok(returnList);
|
|
|
} else if (String.valueOf(NumberConstant.THREE).equals(latitude)) {
|
|
|
-// //开始时间
|
|
|
-// dateStart = DateUtil.getLastWeekDateStartToString(LocalDate.now(), 6);
|
|
|
-// //结束时间
|
|
|
-// dateEnd = DateUtil.getLastWeekDateEndToString(0);
|
|
|
- List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
|
|
|
- for (String dateTime : dateTimeDay) {
|
|
|
-
|
|
|
+ String deviceId = param.getDeviceId();
|
|
|
+ String mountainId = headerData.getMountainId();
|
|
|
+ KwsDevice kwsDevice = deviceMapper.selectOne(new LambdaQueryWrapper<KwsDevice>()
|
|
|
+ .eq(KwsDevice::getId, Long.parseLong(deviceId))
|
|
|
+ .eq(KwsDevice::getMountainId, mountainId)
|
|
|
+ .eq(KwsDevice::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ if (kwsDevice == null) {
|
|
|
+ return HttpResult.ok();
|
|
|
+ }
|
|
|
+// List<String> dateTimeDay = DateUtil.getDateTimeDay(LocalDateTime.now(), 7, new ArrayList<String>());
|
|
|
+ List<Date> dateTimeDay = DateUtil.getDateTimeDayToDate(LocalDateTime.now(), 7, new ArrayList<Date>());
|
|
|
+ for (Date dateTime : dateTimeDay) {
|
|
|
+ //当前设备下的所有基本要素
|
|
|
+ List<ProjectCatLogVO> returnList = new ArrayList<>();
|
|
|
+ basicItemByWeek(mountainId, projectId, deviceId, kwsDevice, returnList, dateTime);
|
|
|
}
|
|
|
/**下面是查询当天每小时数据总量的代码示例:
|
|
|
|
|
|
@@ -492,6 +434,386 @@ public class ProjectService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 周为纬度 折线图计算
|
|
|
+ *
|
|
|
+ * @param mountainId 所属企业
|
|
|
+ * @param projectId 所属项目
|
|
|
+ * @param deviceId 所属设备
|
|
|
+ * @param kwsDevice 设备信息
|
|
|
+ * @param returnList 返回数据
|
|
|
+ * @param date 时间范围
|
|
|
+ */
|
|
|
+ private void basicItemByWeek(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<ProjectCatLogVO> returnList, Date date) {
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
|
|
|
+ if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
+ for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
+ ProjectCatLogVO returnVO = new ProjectCatLogVO();
|
|
|
+ String partName = projectDeviceVO.getPartName();
|
|
|
+ //设置过阈值的基本要素
|
|
|
+ List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
+ .eq(KwsDeviceReference::getType, 1)
|
|
|
+ .eq(KwsDeviceReference::getItem, partName)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
+ if (!CollectionUtils.isEmpty(references)) {
|
|
|
+ deviceReference = references.get(0);
|
|
|
+ }
|
|
|
+ //基准值
|
|
|
+ BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
+ .eq(KwsThreshold::getItemName, partName)
|
|
|
+ .eq(KwsThreshold::getMountainId, mountainId)
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
+ }
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
+ String thresholdMax = "";
|
|
|
+ String thresholdMin = "";
|
|
|
+ if (listMap.get("1") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("1").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+ }
|
|
|
+ returnVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
+ if (listMap.get("2") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("2").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+ }
|
|
|
+ returnVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
+
|
|
|
+ if (listMap.get("3") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("3").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+ }
|
|
|
+ returnVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
+ //时间统计轴(当前数据检测值)
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ if (currentValue != null) {
|
|
|
+ /**存在经纬度海拔值的需要公式计算*/
|
|
|
+ List<String> itemList = new ArrayList<>();
|
|
|
+ itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
+// Date date = new Date();
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
+ 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"));
|
|
|
+ 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 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
+ offsetValue = new BigDecimal(line).subtract(currentValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.clear();
|
|
|
+ itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ datemap.put(key, offsetValue);
|
|
|
+ mapList.add(datemap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnVO.setMapList(mapList);
|
|
|
+ returnList.add(returnVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 集成要素折线图计算
|
|
|
+ */
|
|
|
+ private void integrationItem(HeaderData headerData, String deviceId, KwsDevice kwsDevice, List<ProjectCatLogVO> returnList) {
|
|
|
+ List<KwsDeviceIntegration> deviceIntegrations = deviceIntegrationMapper.selectList(new LambdaQueryWrapper<KwsDeviceIntegration>()
|
|
|
+ .eq(KwsDeviceIntegration::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceIntegration::getDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ List<Long> longList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(deviceIntegrations)) {
|
|
|
+ longList = deviceIntegrations.stream().map(KwsDeviceIntegration::getIntegrationId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(longList)) {
|
|
|
+ List<KwsIntegration> kwsIntegrations = integrationMapper.selectList(new LambdaQueryWrapper<KwsIntegration>().in(KwsIntegration::getId, longList));
|
|
|
+ if (!CollectionUtils.isEmpty(kwsIntegrations) && kwsIntegrations.size() > 0) {
|
|
|
+ kwsIntegrations.forEach(integration -> {
|
|
|
+ ProjectCatLogVO projectCatLogVO = new ProjectCatLogVO();
|
|
|
+ String integrationName = integration.getIntegrationName();
|
|
|
+ String partNames = integration.getPartNames();
|
|
|
+ List<KwsDeviceReference> referenceList = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, Long.parseLong(deviceId))
|
|
|
+ .eq(KwsDeviceReference::getItem, integrationName)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, 0)
|
|
|
+ .eq(KwsDeviceReference::getType, 2)
|
|
|
+ );
|
|
|
+ //当前基准值
|
|
|
+ projectCatLogVO.setReference(CollectionUtils.isEmpty(referenceList) ? null :
|
|
|
+ (referenceList.get(0).getCurrentValue() == null ? null : referenceList.get(0).getCurrentValue()));
|
|
|
+ //当前要素阈值
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
+ .eq(KwsThreshold::getItemName, integrationName)
|
|
|
+ .eq(KwsThreshold::getMountainId, headerData.getMountainId())
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
+ }
|
|
|
+ //阈值等级map
|
|
|
+// Map<String, Map<String, String>> thresholdMap = new HashMap<>();
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
+ String thresholdMax = "";
|
|
|
+ String thresholdMin = "";
|
|
|
+ if (listMap.get("1") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("1").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("oneLevelAlarm", map);
|
|
|
+ projectCatLogVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
+ if (listMap.get("2") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("2").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("twoLevelAlarm", map);
|
|
|
+ projectCatLogVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
+
|
|
|
+ if (listMap.get("3") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("3").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("threeLevelAlarm", map);
|
|
|
+ projectCatLogVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
+
|
|
|
+ //当前测量值-TD获取
|
|
|
+ String formula = integration.getFormula();
|
|
|
+ List<String> stringList = StringUtils.splitStrToList(partNames, String.class);
|
|
|
+ if (!CollectionUtils.isEmpty(stringList)) {
|
|
|
+ for (String item : stringList) {
|
|
|
+ //当前仅有加速度
|
|
|
+ BigDecimal decimal = new BigDecimal("0.00");
|
|
|
+ Date date = new Date();
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ 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.setMapList(mapList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 折线图 基本要素
|
|
|
+ */
|
|
|
+ private void basicItem(String mountainId, String projectId, String deviceId, KwsDevice kwsDevice, List<ProjectCatLogVO> returnList) {
|
|
|
+ List<ProjectDeviceVO> projectDeviceList = projectMapper.selectDeviceByProjectId(mountainId, Long.parseLong(projectId), Long.parseLong(deviceId));
|
|
|
+ if (!CollectionUtils.isEmpty(projectDeviceList)) {
|
|
|
+ for (ProjectDeviceVO projectDeviceVO : projectDeviceList) {
|
|
|
+ ProjectCatLogVO returnVO = new ProjectCatLogVO();
|
|
|
+ String partName = projectDeviceVO.getPartName();
|
|
|
+ //设置过阈值的基本要素
|
|
|
+ List<KwsDeviceReference> references = deviceReferenceMapper.selectList(new LambdaQueryWrapper<KwsDeviceReference>()
|
|
|
+ .eq(KwsDeviceReference::getDeviceId, deviceId)
|
|
|
+ .eq(KwsDeviceReference::getMountainId, mountainId)
|
|
|
+ .eq(KwsDeviceReference::getType, 1)
|
|
|
+ .eq(KwsDeviceReference::getItem, partName)
|
|
|
+ .eq(KwsDeviceReference::getDelFlag, NumberConstant.ZERO)
|
|
|
+ );
|
|
|
+ KwsDeviceReference deviceReference = new KwsDeviceReference();
|
|
|
+ if (!CollectionUtils.isEmpty(references)) {
|
|
|
+ deviceReference = references.get(0);
|
|
|
+ }
|
|
|
+ //基准值
|
|
|
+ BigDecimal currentValue = deviceReference.getCurrentValue();
|
|
|
+ List<KwsThreshold> kwsThresholds = thresholdMapper.selectList(new LambdaQueryWrapper<KwsThreshold>()
|
|
|
+ .eq(KwsThreshold::getDelFlag, 0)
|
|
|
+ .eq(KwsThreshold::getItemName, partName)
|
|
|
+ .eq(KwsThreshold::getMountainId, mountainId)
|
|
|
+ .eq(KwsThreshold::getDeviceId, deviceId)
|
|
|
+ );
|
|
|
+ Map<Integer, List<KwsThreshold>> listMap = new HashMap<>();
|
|
|
+ if (!CollectionUtils.isEmpty(kwsThresholds)) {
|
|
|
+ listMap = kwsThresholds.stream().collect(Collectors.groupingBy(KwsThreshold::getLevel));
|
|
|
+ }
|
|
|
+ //阈值等级map
|
|
|
+// Map<String, Map<String, String>> thresholdMap = new HashMap<>();
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
+ ThresholdLevelVO thresholdLevelVO = new ThresholdLevelVO();
|
|
|
+ String thresholdMax = "";
|
|
|
+ String thresholdMin = "";
|
|
|
+ if (listMap.get("1") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("1").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("oneLevelAlarm", map);
|
|
|
+ returnVO.setOneLevelAlarm(thresholdLevelVO);
|
|
|
+ if (listMap.get("2") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("2").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("twoLevelAlarm", map);
|
|
|
+ returnVO.setTwoLevelAlarm(thresholdLevelVO);
|
|
|
+
|
|
|
+ if (listMap.get("3") != null) {
|
|
|
+ KwsThreshold kwsThreshold = listMap.get("3").get(0);
|
|
|
+ thresholdMax = kwsThreshold.getMax();
|
|
|
+ thresholdMin = kwsThreshold.getMin();
|
|
|
+ thresholdLevelVO.setThresholdMax(thresholdMax);
|
|
|
+ thresholdLevelVO.setThresholdMin(thresholdMin);
|
|
|
+// map.put("thresholdMax", thresholdMax);
|
|
|
+// map.put("thresholdMin", thresholdMin);
|
|
|
+ }
|
|
|
+// thresholdMap.put("threeLevelAlarm", map);
|
|
|
+ returnVO.setThreeLevelAlarm(thresholdLevelVO);
|
|
|
+ //时间统计轴(当前数据检测值)
|
|
|
+ List<Map<String, Object>> mapList = new ArrayList<>();
|
|
|
+ if (currentValue != null) {
|
|
|
+ /**存在经纬度海拔值的需要公式计算*/
|
|
|
+ List<String> itemList = new ArrayList<>();
|
|
|
+ itemList.add(DictItemEnum.LONGITUDE_X.getValue());
|
|
|
+ Date date = new Date();
|
|
|
+ String dateStart = DateUtil.getDateTimeToHour(date, 24);
|
|
|
+ String dateEnd = DateUtil.localDateTimeFormat(LocalDateTime.now());
|
|
|
+ List<SlopeData> selected = slopeDataMapper.selectLineList(kwsDevice.getSnCode(), partName, dateStart, dateEnd);
|
|
|
+ if (!CollectionUtils.isEmpty(selected)) {
|
|
|
+ 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"));
|
|
|
+ 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 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.add(DictItemEnum.LATITUDE_Y.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
+ offsetValue = new BigDecimal(line).subtract(currentValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemList.clear();
|
|
|
+ itemList.add(DictItemEnum.ALTITUDE_Z.getValue());
|
|
|
+ if (itemList.contains(partName)) {
|
|
|
+ if (Objects.nonNull(currentValue)) {
|
|
|
+ if (org.apache.commons.lang3.StringUtils.isNotBlank(line)) {
|
|
|
+ offsetValue = new BigDecimal(line).divide(new BigDecimal(1000));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ datemap.put(key, offsetValue);
|
|
|
+ mapList.add(datemap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ returnVO.setMapList(mapList);
|
|
|
+ returnList.add(returnVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 项目关联设备删除
|